/*ALTAMTENTE BELHOTESS!!!!!!!!
 * fsdfgdsgdfgf
 * GCSView.java
 */

package gcs.Interface;

import gcs.Negocio.*;
import gcs.Dados.ClientesBD;
import java.awt.Color;
import java.awt.Component;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import java.util.Calendar;
import javax.swing.DefaultListModel;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 * The application's main frame.
 */
public class GCSView extends FrameView {

    int optn = 0; //usado para alterar/adicionar cliente
    private Empresa empAct;
    private Servico servAct;
    private Actividade actAct;
    private int tipoCria; // 0 - empresa,1 - servico, 2 - actividade
    private GCS gcs;
    int met;
    Utilizador util;
    DefaultListModel model_util;
    DefaultListModel modelContractos;
    DefaultListModel modelClientes;
    DefaultListModel model_empresas;
    DefaultListModel model_servicos;
    DefaultListModel model_actividades;
    public GCSView(SingleFrameApplication app) {
        super(app);
        
        gcs = new GCS();
        gcs.leRestantes();
        initComponents();
        
        detalhes_tab2(false);
        detalhes_tab2_clear();



        refresh_lists();


        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }
    //true = os detalhes do item selecionado sao mostrados
    private void detalhes_tab1(boolean b){
        jTextField_nome.setEnabled(b);
        jTextArea_desc.setEnabled(b);
        jTextField_preco.setEnabled(b);
    }
    public void botoes_tab2(boolean b){
        jButton_Acliente.setEnabled(b);
        jButton_Rcliente.setEnabled(b);
        jButton_historico.setEnabled(b);
        jButton_adicionarConctracto.setEnabled(b);
        jButton_cancelarContracto.setEnabled(b);
        jButton_alterarCliente.setEnabled(b);
        jButton_adicionarActividade.setEnabled(b);

        jTextField4.setEnabled(b);
        jTextField5.setEnabled(b);
        jList4.setEnabled(b);
        jList5.setEnabled(b);
        jList6.setEnabled(b);
    }
    public void detalhes_tab2(boolean b){
        jTextField_nomeCliente.setEnabled(b);
        jTextField_BI.setEnabled(b);
        jTextField_NIF.setEnabled(b);
        jTextArea_morada.setEnabled(b);
        jTextField_Empresa.setEnabled(b);
        jTextField_servico.setEnabled(b);
        jTextField_data.setEnabled(b);
        jTextArea_descrisaoActividadeContracto.setEnabled(b);

        jButton_confirmaAdicionarCliente.setVisible(b);
        jButton_cancelaAdicionarCliente.setVisible(b);
    }
    private void detalhes_tab1_clear(){
        jTextField_nome.setText(null);
        jTextArea_desc.setText(null);
        jTextField_preco.setText(null);
    }
    private void detalhes_tab2_clear(){
        jTextField_nomeCliente.setText(null);
        jTextField_BI.setText(null);
        jTextField_NIF.setText(null);
        jTextArea_morada.setText(null);
        jTextField_Empresa.setText(null);
        jTextField_servico.setText(null);
        jList6.setModel(new DefaultListModel());
        jTextField_data.setText(null);
        jTextArea_descrisaoActividadeContracto.setText(null);
    }
    private void detalhes_tabEditable(boolean b){
        jTextField_nome.setEditable(b);
        jTextArea_desc.setEditable(b);
        jTextField_preco.setEditable(b);
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = GCSApp.getApplication().getMainFrame();
            aboutBox = new GCSAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        GCSApp.getApplication().show(aboutBox);
    }

    public void refresh(){
        model_util = new DefaultListModel();
        gcs.leUtilizadores();
        for(Utilizador u : GCS.getUtilizadores().values())
            model_util.addElement(u.getUser());
        jListUtil.setModel(model_util);
    }

    public void opbutton(){
        jTextFieldProcUtil.setEnabled(true);
        jListUtil.setEnabled(true);
        jButtonAlt.setEnabled(true);
        jButtonCriar.setEnabled(true);
        jButtonInact.setEnabled(true);
        jButtonGuardar.setVisible(false);
        Cancelar.setVisible(false);
        jTextFieldUser.setEnabled(false);
        jPasswordField1.setEnabled(false);
        jListUtil.clearSelection();
        jTextFieldUser.setText("");
        jPasswordField1.setText("");
        jCheckBoxAct.setSelected(true);
        jComboBoxTipo.setSelectedItem("Normal");
        jLabelMethod.setText("");
        if(util.getTipo()==1){
            jCheckBoxAct.setEnabled(false);
            jComboBoxTipo.setEnabled(false);
        }
        else
            jButtonAlt.setEnabled(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jTabbedPane = new javax.swing.JTabbedPane();
        jPanelEmpresas = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jScrollPane3 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList();
        jScrollPane4 = new javax.swing.JScrollPane();
        jList3 = new javax.swing.JList();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jButton_Aemp = new javax.swing.JButton();
        jButton_Aserv = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jButton_InacEmp = new javax.swing.JButton();
        jButton_InactServ = new javax.swing.JButton();
        jButton_InactAct = new javax.swing.JButton();
        jButton_Aact = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel_nome = new javax.swing.JLabel();
        jLabel_desc = new javax.swing.JLabel();
        jTextField_nome = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea_desc = new javax.swing.JTextArea();
        jLabel_preco = new javax.swing.JLabel();
        jTextField_preco = new javax.swing.JTextField();
        jLabel_euros = new javax.swing.JLabel();
        jLabel_activo = new javax.swing.JLabel();
        jButton_guardarESA = new javax.swing.JButton();
        jButton_cancelarESA = new javax.swing.JButton();
        jComboBox_tipoServ = new javax.swing.JComboBox();
        jButton_guardaAlt = new javax.swing.JButton();
        jButton_alterarEmp = new javax.swing.JButton();
        jButton_alterarServ = new javax.swing.JButton();
        jButton_alterarAct = new javax.swing.JButton();
        jLabel_tipoS = new javax.swing.JLabel();
        jPanelClientes = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jList4 = new javax.swing.JList();
        jScrollPane7 = new javax.swing.JScrollPane();
        jList5 = new javax.swing.JList();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jButton_Acliente = new javax.swing.JButton();
        jButton_adicionarConctracto = new javax.swing.JButton();
        jButton_adicionarActividade = new javax.swing.JButton();
        jButton_cancelarContracto = new javax.swing.JButton();
        jButton_historico = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JSeparator();
        jButton_Rcliente = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jTextField_nomeCliente = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jTextField_BI = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jTextField_NIF = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jSeparator3 = new javax.swing.JSeparator();
        jLabel12 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTextArea_morada = new javax.swing.JTextArea();
        jLabel13 = new javax.swing.JLabel();
        jTextField_Empresa = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jTextField_servico = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jScrollPane8 = new javax.swing.JScrollPane();
        jList6 = new javax.swing.JList();
        jTextField_data = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jScrollPane9 = new javax.swing.JScrollPane();
        jTextArea_descrisaoActividadeContracto = new javax.swing.JTextArea();
        jButton_confirmaAdicionarCliente = new javax.swing.JButton();
        jButton_cancelaAdicionarCliente = new javax.swing.JButton();
        jButton_alterarCliente = new javax.swing.JButton();
        jPanelPagamentos = new javax.swing.JPanel();
        jButtonPagar = new javax.swing.JButton();
        jComboClientes48 = new javax.swing.JComboBox();
        jlabelemanuel1 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jComboBoxContracto48 = new javax.swing.JComboBox();
        jScrollPane10 = new javax.swing.JScrollPane();
        jListPrestacoes48 = new javax.swing.JList();
        jLabel20 = new javax.swing.JLabel();
        jLabelDataLimite48 = new javax.swing.JLabel();
        jLabelVP48 = new javax.swing.JLabel();
        jTextFieldDataLim48 = new javax.swing.JTextField();
        jTextFieldVP48 = new javax.swing.JTextField();
        jLabelPaga = new javax.swing.JLabel();
        jButtonConfirmar48 = new javax.swing.JButton();
        jButtonHist48 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jComboBox_tipoServTS = new javax.swing.JComboBox();
        jLabel_tipoServTS = new javax.swing.JLabel();
        jButton_addTS = new javax.swing.JButton();
        jButton_alterarTS = new javax.swing.JButton();
        jTextField_nomeTS = new javax.swing.JTextField();
        jLabel_nomeTS = new javax.swing.JLabel();
        jButton_cancelarTS = new javax.swing.JButton();
        jButton_guardarTS = new javax.swing.JButton();
        jButton_guardaAltTS = new javax.swing.JButton();
        jPanelUtilizadores = new javax.swing.JPanel();
        jScrollPane11 = new javax.swing.JScrollPane();
        jListUtil = new javax.swing.JList();
        jLabelProcUtil = new javax.swing.JLabel();
        jTextFieldProcUtil = new javax.swing.JTextField();
        jLabelUser = new javax.swing.JLabel();
        jLabelPass = new javax.swing.JLabel();
        jLabelTipo = new javax.swing.JLabel();
        jTextFieldUser = new javax.swing.JTextField();
        jComboBoxTipo = new javax.swing.JComboBox();
        jLabelAct = new javax.swing.JLabel();
        jCheckBoxAct = new javax.swing.JCheckBox();
        jButtonCriar = new javax.swing.JButton();
        jButtonAlt = new javax.swing.JButton();
        jLabelMethod = new javax.swing.JLabel();
        jButtonInact = new javax.swing.JButton();
        jButtonGuardar = new javax.swing.JButton();
        Cancelar = new javax.swing.JButton();
        jPasswordField1 = new javax.swing.JPasswordField();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(GCSView.class);
        mainPanel.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
        mainPanel.setName("mainPanel"); // NOI18N

        jTabbedPane.setBackground(resourceMap.getColor("jTabbedPane.background")); // NOI18N
        jTabbedPane.setName("jTabbedPane"); // NOI18N
        jTabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jTabbedPaneStateChanged(evt);
            }
        });

        jPanelEmpresas.setBackground(resourceMap.getColor("jPanelEmpresas.background")); // NOI18N
        jPanelEmpresas.setName("jPanelEmpresas"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList1.setName("jList1"); // NOI18N
        jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jList1ValueChanged(evt);
            }
        });
        jScrollPane2.setViewportView(jList1);

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        jList2.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList2.setEnabled(false);
        jList2.setName("jList2"); // NOI18N
        jList2.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jList2ValueChanged(evt);
            }
        });
        jScrollPane3.setViewportView(jList2);

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        jList3.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList3.setEnabled(false);
        jList3.setName("jList3"); // NOI18N
        jList3.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jList3ValueChanged(evt);
            }
        });
        jScrollPane4.setViewportView(jList3);

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jButton_Aemp.setIcon(resourceMap.getIcon("jButton_Aemp.icon")); // NOI18N
        jButton_Aemp.setText(resourceMap.getString("jButton_Aemp.text")); // NOI18N
        jButton_Aemp.setName("jButton_Aemp"); // NOI18N
        jButton_Aemp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_AempActionPerformed(evt);
            }
        });

        jButton_Aserv.setIcon(resourceMap.getIcon("jButton_Aserv.icon")); // NOI18N
        jButton_Aserv.setText(resourceMap.getString("jButton_Aserv.text")); // NOI18N
        jButton_Aserv.setName("jButton_Aserv"); // NOI18N
        jButton_Aserv.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_AservActionPerformed(evt);
            }
        });

        jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N
        jTextField1.setName("jTextField1"); // NOI18N
        jTextField1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTextField1FocusGained(evt);
            }
        });
        jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextField1KeyReleased(evt);
            }
        });

        jTextField2.setText(resourceMap.getString("jTextField2.text")); // NOI18N
        jTextField2.setName("jTextField2"); // NOI18N
        jTextField2.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTextField2FocusGained(evt);
            }
        });
        jTextField2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextField2KeyReleased(evt);
            }
        });

        jTextField3.setText(resourceMap.getString("jTextField3.text")); // NOI18N
        jTextField3.setName("jTextField3"); // NOI18N
        jTextField3.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTextField3FocusGained(evt);
            }
        });
        jTextField3.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextField3KeyReleased(evt);
            }
        });

        jButton_InacEmp.setIcon(resourceMap.getIcon("jButton_InacEmp.icon")); // NOI18N
        jButton_InacEmp.setText(resourceMap.getString("jButton_InacEmp.text")); // NOI18N
        jButton_InacEmp.setName("jButton_InacEmp"); // NOI18N
        jButton_InacEmp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_InacEmpActionPerformed(evt);
            }
        });

        jButton_InactServ.setIcon(resourceMap.getIcon("jButton_InactServ.icon")); // NOI18N
        jButton_InactServ.setText(resourceMap.getString("jButton_InactServ.text")); // NOI18N
        jButton_InactServ.setName("jButton_InactServ"); // NOI18N
        jButton_InactServ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_InactServActionPerformed(evt);
            }
        });

        jButton_InactAct.setIcon(resourceMap.getIcon("jButton_InactAct.icon")); // NOI18N
        jButton_InactAct.setText(resourceMap.getString("jButton_InactAct.text")); // NOI18N
        jButton_InactAct.setName("jButton_InactAct"); // NOI18N
        jButton_InactAct.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_InactActActionPerformed(evt);
            }
        });

        jButton_Aact.setIcon(resourceMap.getIcon("jButton_Aact.icon")); // NOI18N
        jButton_Aact.setText(resourceMap.getString("jButton_Aact.text")); // NOI18N
        jButton_Aact.setName("jButton_Aact"); // NOI18N
        jButton_Aact.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_AactActionPerformed(evt);
            }
        });

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator1.setName("jSeparator1"); // NOI18N

        jLabel_nome.setText(resourceMap.getString("jLabel_nome.text")); // NOI18N
        jLabel_nome.setName("jLabel_nome"); // NOI18N

        jLabel_desc.setText(resourceMap.getString("jLabel_desc.text")); // NOI18N
        jLabel_desc.setName("jLabel_desc"); // NOI18N

        jTextField_nome.setName("jTextField_nome"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTextArea_desc.setColumns(10);
        jTextArea_desc.setRows(3);
        jTextArea_desc.setBorder(null);
        jTextArea_desc.setHighlighter(null);
        jTextArea_desc.setName("jTextArea_desc"); // NOI18N
        jScrollPane1.setViewportView(jTextArea_desc);

        jLabel_preco.setText(resourceMap.getString("jLabel_preco.text")); // NOI18N
        jLabel_preco.setName("jLabel_preco"); // NOI18N

        jTextField_preco.setName("jTextField_preco"); // NOI18N

        jLabel_euros.setText(resourceMap.getString("jLabel_euros.text")); // NOI18N
        jLabel_euros.setName("jLabel_euros"); // NOI18N

        jLabel_activo.setText(resourceMap.getString("jLabel_activo.text")); // NOI18N
        jLabel_activo.setName("jLabel_activo"); // NOI18N

        jButton_guardarESA.setIcon(resourceMap.getIcon("jButton_guardarESA.icon")); // NOI18N
        jButton_guardarESA.setText(resourceMap.getString("jButton_guardarESA.text")); // NOI18N
        jButton_guardarESA.setEnabled(false);
        jButton_guardarESA.setName("jButton_guardarESA"); // NOI18N
        jButton_guardarESA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_guardarESAActionPerformed(evt);
            }
        });

        jButton_cancelarESA.setIcon(resourceMap.getIcon("jButton_cancelarESA.icon")); // NOI18N
        jButton_cancelarESA.setText(resourceMap.getString("jButton_cancelarESA.text")); // NOI18N
        jButton_cancelarESA.setEnabled(false);
        jButton_cancelarESA.setName("jButton_cancelarESA"); // NOI18N
        jButton_cancelarESA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_cancelarESAActionPerformed(evt);
            }
        });

        jComboBox_tipoServ.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox_tipoServ.setName("jComboBox_tipoServ"); // NOI18N
        jComboBox_tipoServ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox_tipoServActionPerformed(evt);
            }
        });

        jButton_guardaAlt.setIcon(resourceMap.getIcon("jButton_guardaAlt.icon")); // NOI18N
        jButton_guardaAlt.setText(resourceMap.getString("jButton_guardaAlt.text")); // NOI18N
        jButton_guardaAlt.setName("jButton_guardaAlt"); // NOI18N
        jButton_guardaAlt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_guardaAltActionPerformed(evt);
            }
        });

        jButton_alterarEmp.setIcon(resourceMap.getIcon("jButton_alterarEmp.icon")); // NOI18N
        jButton_alterarEmp.setText(resourceMap.getString("jButton_alterarEmp.text")); // NOI18N
        jButton_alterarEmp.setName("jButton_alterarEmp"); // NOI18N
        jButton_alterarEmp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_alterarEmpActionPerformed(evt);
            }
        });

        jButton_alterarServ.setIcon(resourceMap.getIcon("jButton_alterarServ.icon")); // NOI18N
        jButton_alterarServ.setText(resourceMap.getString("jButton_alterarServ.text")); // NOI18N
        jButton_alterarServ.setName("jButton_alterarServ"); // NOI18N
        jButton_alterarServ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_alterarServActionPerformed(evt);
            }
        });

        jButton_alterarAct.setIcon(resourceMap.getIcon("jButton_alterarAct.icon")); // NOI18N
        jButton_alterarAct.setText(resourceMap.getString("jButton_alterarAct.text")); // NOI18N
        jButton_alterarAct.setName("jButton_alterarAct"); // NOI18N
        jButton_alterarAct.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_alterarActActionPerformed(evt);
            }
        });

        jLabel_tipoS.setText(resourceMap.getString("jLabel_tipoS.text")); // NOI18N
        jLabel_tipoS.setName("jLabel_tipoS"); // NOI18N

        javax.swing.GroupLayout jPanelEmpresasLayout = new javax.swing.GroupLayout(jPanelEmpresas);
        jPanelEmpresas.setLayout(jPanelEmpresasLayout);
        jPanelEmpresasLayout.setHorizontalGroup(
            jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel1)
                    .addComponent(jButton_InacEmp)
                    .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                        .addComponent(jButton_Aemp)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton_alterarEmp))
                    .addComponent(jTextField1)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel2)
                    .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                    .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                        .addComponent(jButton_Aserv)
                        .addGap(18, 18, 18)
                        .addComponent(jButton_alterarServ))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)
                    .addComponent(jButton_InactServ, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel3)
                    .addComponent(jButton_InactAct, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                        .addComponent(jButton_Aact, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton_alterarAct))
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 165, Short.MAX_VALUE)
                    .addComponent(jTextField3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel_desc)
                                .addContainerGap())
                            .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField_nome, javax.swing.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
                                .addContainerGap())
                            .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel_nome)
                                    .addComponent(jLabel4))
                                .addGap(253, 253, 253))
                            .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                                .addGap(6, 6, 6)
                                .addComponent(jTextField_preco, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel_euros)
                                .addGap(231, 231, 231))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelEmpresasLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
                                .addContainerGap()))
                        .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jLabel_preco)
                            .addContainerGap())
                        .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                                    .addComponent(jLabel_tipoS)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jComboBox_tipoServ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jLabel_activo))
                            .addGap(204, 204, 204)))
                    .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jButton_cancelarESA, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton_guardaAlt, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton_guardarESA, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        jPanelEmpresasLayout.setVerticalGroup(
            jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelEmpresasLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(35, 35, 35)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton_InacEmp)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton_Aemp)
                            .addComponent(jButton_alterarEmp)))
                    .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(9, 9, 9)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton_InactAct)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton_Aact)
                            .addComponent(jButton_alterarAct)
                            .addComponent(jButton_alterarServ)))
                    .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(9, 9, 9)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton_InactServ)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton_Aserv))
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 391, Short.MAX_VALUE)
                    .addGroup(jPanelEmpresasLayout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(11, 11, 11)
                        .addComponent(jLabel_nome)
                        .addGap(4, 4, 4)
                        .addComponent(jTextField_nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel_desc)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel_preco)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField_preco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel_euros))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBox_tipoServ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel_tipoS))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel_activo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 59, Short.MAX_VALUE)
                        .addGroup(jPanelEmpresasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton_guardarESA, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton_guardaAlt)
                            .addComponent(jButton_cancelarESA, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );

        jTabbedPane.addTab("Empresas", jPanelEmpresas);

        jPanelClientes.setBackground(resourceMap.getColor("jPanelEmpresas.background")); // NOI18N
        jPanelClientes.setName("jPanelClientes"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jScrollPane6.setName("jScrollPane6"); // NOI18N

        jList4.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList4.setName("jList4"); // NOI18N
        jList4.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jList4ValueChanged(evt);
            }
        });
        jScrollPane6.setViewportView(jList4);

        jScrollPane7.setName("jScrollPane7"); // NOI18N

        jList5.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList5.setName("jList5"); // NOI18N
        jList5.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jList5ValueChanged(evt);
            }
        });
        jScrollPane7.setViewportView(jList5);

        jTextField4.setText(resourceMap.getString("jTextField4.text")); // NOI18N
        jTextField4.setName("jTextField4"); // NOI18N
        jTextField4.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTextField4FocusGained(evt);
            }
        });
        jTextField4.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextField4KeyReleased(evt);
            }
        });

        jTextField5.setText(resourceMap.getString("jTextField5.text")); // NOI18N
        jTextField5.setName("jTextField5"); // NOI18N
        jTextField5.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTextField5FocusGained(evt);
            }
        });
        jTextField5.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextField5KeyReleased(evt);
            }
        });

        jButton_Acliente.setIcon(resourceMap.getIcon("jButton_Acliente.icon")); // NOI18N
        jButton_Acliente.setText(resourceMap.getString("jButton_Acliente.text")); // NOI18N
        jButton_Acliente.setName("jButton_Acliente"); // NOI18N
        jButton_Acliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_AclienteActionPerformed(evt);
            }
        });

        jButton_adicionarConctracto.setIcon(resourceMap.getIcon("jButton_adicionarConctracto.icon")); // NOI18N
        jButton_adicionarConctracto.setText(resourceMap.getString("jButton_adicionarConctracto.text")); // NOI18N
        jButton_adicionarConctracto.setName("jButton_adicionarConctracto"); // NOI18N
        jButton_adicionarConctracto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_adicionarConctractoActionPerformed(evt);
            }
        });

        jButton_adicionarActividade.setText(resourceMap.getString("jButton_adicionarActividade.text")); // NOI18N
        jButton_adicionarActividade.setName("jButton_adicionarActividade"); // NOI18N
        jButton_adicionarActividade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_adicionarActividadeActionPerformed(evt);
            }
        });

        jButton_cancelarContracto.setIcon(resourceMap.getIcon("jButton_cancelarContracto.icon")); // NOI18N
        jButton_cancelarContracto.setText(resourceMap.getString("jButton_cancelarContracto.text")); // NOI18N
        jButton_cancelarContracto.setName("jButton_cancelarContracto"); // NOI18N
        jButton_cancelarContracto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_cancelarContractoActionPerformed(evt);
            }
        });

        jButton_historico.setIcon(resourceMap.getIcon("jButton_historico.icon")); // NOI18N
        jButton_historico.setText(resourceMap.getString("jButton_historico.text")); // NOI18N
        jButton_historico.setName("jButton_historico"); // NOI18N
        jButton_historico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_historicoActionPerformed(evt);
            }
        });

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator2.setName("jSeparator2"); // NOI18N

        jButton_Rcliente.setIcon(resourceMap.getIcon("jButton_Rcliente.icon")); // NOI18N
        jButton_Rcliente.setText(resourceMap.getString("jButton_Rcliente.text")); // NOI18N
        jButton_Rcliente.setName("jButton_Rcliente"); // NOI18N
        jButton_Rcliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_RclienteActionPerformed(evt);
            }
        });

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jTextField_nomeCliente.setText(resourceMap.getString("jTextField_nomeCliente.text")); // NOI18N
        jTextField_nomeCliente.setName("jTextField_nomeCliente"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jTextField_BI.setText(resourceMap.getString("jTextField_BI.text")); // NOI18N
        jTextField_BI.setName("jTextField_BI"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jTextField_NIF.setText(resourceMap.getString("jTextField_NIF.text")); // NOI18N
        jTextField_NIF.setName("jTextField_NIF"); // NOI18N

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator3.setName("jSeparator3"); // NOI18N

        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        jScrollPane5.setName("jScrollPane5"); // NOI18N

        jTextArea_morada.setColumns(20);
        jTextArea_morada.setRows(3);
        jTextArea_morada.setName("jTextArea_morada"); // NOI18N
        jScrollPane5.setViewportView(jTextArea_morada);

        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N

        jTextField_Empresa.setEditable(false);
        jTextField_Empresa.setText(resourceMap.getString("jTextField_Empresa.text")); // NOI18N
        jTextField_Empresa.setName("jTextField_Empresa"); // NOI18N

        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N

        jTextField_servico.setEditable(false);
        jTextField_servico.setName("jTextField_servico"); // NOI18N

        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N

        jScrollPane8.setName("jScrollPane8"); // NOI18N

        jList6.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList6.setName("jList6"); // NOI18N
        jList6.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jList6ValueChanged(evt);
            }
        });
        jScrollPane8.setViewportView(jList6);

        jTextField_data.setEditable(false);
        jTextField_data.setText(resourceMap.getString("jTextField_data.text")); // NOI18N
        jTextField_data.setName("jTextField_data"); // NOI18N

        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jLabel16.setName("jLabel16"); // NOI18N

        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N

        jScrollPane9.setName("jScrollPane9"); // NOI18N

        jTextArea_descrisaoActividadeContracto.setColumns(20);
        jTextArea_descrisaoActividadeContracto.setEditable(false);
        jTextArea_descrisaoActividadeContracto.setRows(3);
        jTextArea_descrisaoActividadeContracto.setName("jTextArea_descrisaoActividadeContracto"); // NOI18N
        jScrollPane9.setViewportView(jTextArea_descrisaoActividadeContracto);

        jButton_confirmaAdicionarCliente.setIcon(resourceMap.getIcon("jButton_confirmaAdicionarCliente.icon")); // NOI18N
        jButton_confirmaAdicionarCliente.setText(resourceMap.getString("jButton_confirmaAdicionarCliente.text")); // NOI18N
        jButton_confirmaAdicionarCliente.setName("jButton_confirmaAdicionarCliente"); // NOI18N
        jButton_confirmaAdicionarCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_confirmaAdicionarClienteActionPerformed(evt);
            }
        });

        jButton_cancelaAdicionarCliente.setIcon(resourceMap.getIcon("jButton_cancelaAdicionarCliente.icon")); // NOI18N
        jButton_cancelaAdicionarCliente.setText(resourceMap.getString("jButton_cancelaAdicionarCliente.text")); // NOI18N
        jButton_cancelaAdicionarCliente.setName("jButton_cancelaAdicionarCliente"); // NOI18N
        jButton_cancelaAdicionarCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_cancelaAdicionarClienteActionPerformed(evt);
            }
        });

        jButton_alterarCliente.setIcon(resourceMap.getIcon("jButton_alterarCliente.icon")); // NOI18N
        jButton_alterarCliente.setText(resourceMap.getString("jButton_alterarCliente.text")); // NOI18N
        jButton_alterarCliente.setName("jButton_alterarCliente"); // NOI18N
        jButton_alterarCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_alterarClienteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelClientesLayout = new javax.swing.GroupLayout(jPanelClientes);
        jPanelClientes.setLayout(jPanelClientesLayout);
        jPanelClientesLayout.setHorizontalGroup(
            jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelClientesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jTextField4, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE))
                    .addComponent(jLabel5)
                    .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jButton_historico, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton_Rcliente, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jButton_Acliente))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jTextField5)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)
                    .addComponent(jLabel6)
                    .addComponent(jButton_cancelarContracto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton_adicionarConctracto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jScrollPane5)
                        .addComponent(jLabel7)
                        .addComponent(jLabel8)
                        .addComponent(jLabel9)
                        .addComponent(jLabel10)
                        .addComponent(jLabel11)
                        .addComponent(jTextField_NIF)
                        .addComponent(jTextField_BI)
                        .addComponent(jTextField_nomeCliente, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE))
                    .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jButton_alterarCliente, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton_cancelaAdicionarCliente, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton_confirmaAdicionarCliente, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelClientesLayout.createSequentialGroup()
                        .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextField_Empresa, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextField_servico, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)
                                .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(jLabel15))
                        .addGap(21, 21, 21)
                        .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel16)
                            .addComponent(jLabel17)
                            .addComponent(jScrollPane9)
                            .addComponent(jTextField_data)))
                    .addComponent(jButton_adicionarActividade, javax.swing.GroupLayout.DEFAULT_SIZE, 507, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanelClientesLayout.setVerticalGroup(
            jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelClientesLayout.createSequentialGroup()
                .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelClientesLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE)
                            .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelClientesLayout.createSequentialGroup()
                                .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelClientesLayout.createSequentialGroup()
                                        .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jLabel6)
                                            .addComponent(jLabel5))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                                            .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jButton_cancelarContracto)
                                            .addComponent(jButton_historico))
                                        .addGroup(jPanelClientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanelClientesLayout.createSequentialGroup()
                                                .addGap(17, 17, 17)
                                                .addComponent(jButton_adicionarConctracto))
                                            .addGroup(jPanelClientesLayout.createSequentialGroup()
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jButton_Rcliente, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jButton_Acliente, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                    .addGroup(jPanelClientesLayout.createSequentialGroup()
                                        .addComponent(jLabel7)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jTextField_nomeCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel9)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jTextField_BI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel10)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jTextField_NIF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel11)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jButton_confirmaAdicionarCliente)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jButton_cancelaAdicionarCliente)))
                                .addGap(12, 12, 12)
                                .addComponent(jButton_alterarCliente))
                            .addGroup(jPanelClientesLayout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField_Empresa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel14)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField_servico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel15)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(189, 189, 189))))
                    .addGroup(jPanelClientesLayout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField_data, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(52, 52, 52)
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 243, Short.MAX_VALUE)
                        .addComponent(jButton_adicionarActividade)))
                .addContainerGap())
        );

        jTabbedPane.addTab(resourceMap.getString("jPanelClientes.TabConstraints.tabTitle"), jPanelClientes); // NOI18N

        jPanelPagamentos.setBackground(resourceMap.getColor("jPanelEmpresas.background")); // NOI18N
        jPanelPagamentos.setName("jPanelPagamentos"); // NOI18N

        jButtonPagar.setIcon(resourceMap.getIcon("jButtonPagar.icon")); // NOI18N
        jButtonPagar.setText(resourceMap.getString("jButtonPagar.text")); // NOI18N
        jButtonPagar.setName("jButtonPagar"); // NOI18N
        jButtonPagar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPagarActionPerformed(evt);
            }
        });

        jComboClientes48.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboClientes48.setName("jComboClientes48"); // NOI18N
        jComboClientes48.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jComboClientes48MousePressed(evt);
            }
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jComboClientes48MouseClicked(evt);
            }
        });
        jComboClientes48.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboClientes48ActionPerformed(evt);
            }
        });

        jlabelemanuel1.setText(resourceMap.getString("jlabelemanuel1.text")); // NOI18N
        jlabelemanuel1.setName("jlabelemanuel1"); // NOI18N

        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N

        jComboBoxContracto48.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBoxContracto48.setName("jComboBoxContracto48"); // NOI18N
        jComboBoxContracto48.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxContracto48ActionPerformed(evt);
            }
        });

        jScrollPane10.setName("jScrollPane10"); // NOI18N

        jListPrestacoes48.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jListPrestacoes48.setName("jListPrestacoes48"); // NOI18N
        jListPrestacoes48.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jListPrestacoes48MouseClicked(evt);
            }
        });
        jScrollPane10.setViewportView(jListPrestacoes48);

        jLabel20.setText(resourceMap.getString("jLabel20.text")); // NOI18N
        jLabel20.setName("jLabel20"); // NOI18N

        jLabelDataLimite48.setText(resourceMap.getString("jLabelDataLimite48.text")); // NOI18N
        jLabelDataLimite48.setName("jLabelDataLimite48"); // NOI18N

        jLabelVP48.setText(resourceMap.getString("jLabelVP48.text")); // NOI18N
        jLabelVP48.setName("jLabelVP48"); // NOI18N

        jTextFieldDataLim48.setEditable(false);
        jTextFieldDataLim48.setName("jTextFieldDataLim48"); // NOI18N

        jTextFieldVP48.setEditable(false);
        jTextFieldVP48.setName("jTextFieldVP48"); // NOI18N

        jLabelPaga.setName("jLabelPaga"); // NOI18N

        jButtonConfirmar48.setIcon(resourceMap.getIcon("jButtonConfirmar48.icon")); // NOI18N
        jButtonConfirmar48.setText(resourceMap.getString("jButtonConfirmar48.text")); // NOI18N
        jButtonConfirmar48.setName("jButtonConfirmar48"); // NOI18N
        jButtonConfirmar48.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonConfirmar48ActionPerformed(evt);
            }
        });

        jButtonHist48.setIcon(resourceMap.getIcon("jButtonHist48.icon")); // NOI18N
        jButtonHist48.setText(resourceMap.getString("jButtonHist48.text")); // NOI18N
        jButtonHist48.setName("jButtonHist48"); // NOI18N
        jButtonHist48.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonHist48MouseClicked(evt);
            }
        });
        jButtonHist48.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonHist48ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelPagamentosLayout = new javax.swing.GroupLayout(jPanelPagamentos);
        jPanelPagamentos.setLayout(jPanelPagamentosLayout);
        jPanelPagamentosLayout.setHorizontalGroup(
            jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelPagamentosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelPagamentosLayout.createSequentialGroup()
                        .addComponent(jLabel20)
                        .addContainerGap(1002, Short.MAX_VALUE))
                    .addGroup(jPanelPagamentosLayout.createSequentialGroup()
                        .addGroup(jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jlabelemanuel1)
                            .addGroup(jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jScrollPane10, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
                                .addComponent(jComboBoxContracto48, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jComboClientes48, javax.swing.GroupLayout.Alignment.LEADING, 0, 317, Short.MAX_VALUE))
                            .addComponent(jLabel19))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanelPagamentosLayout.createSequentialGroup()
                                    .addGroup(jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addGroup(jPanelPagamentosLayout.createSequentialGroup()
                                            .addGap(51, 51, 51)
                                            .addComponent(jTextFieldVP48))
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelPagamentosLayout.createSequentialGroup()
                                            .addGap(52, 52, 52)
                                            .addComponent(jTextFieldDataLim48, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addContainerGap())
                                .addGroup(jPanelPagamentosLayout.createSequentialGroup()
                                    .addComponent(jLabelPaga, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
                                    .addGap(541, 541, 541)))
                            .addGroup(jPanelPagamentosLayout.createSequentialGroup()
                                .addGap(29, 29, 29)
                                .addGroup(jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelVP48)
                                    .addGroup(jPanelPagamentosLayout.createSequentialGroup()
                                        .addComponent(jButtonHist48)
                                        .addGap(147, 147, 147)
                                        .addGroup(jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jButtonPagar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jButtonConfirmar48, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addComponent(jLabelDataLimite48))
                                .addGap(260, 260, 260))))))
        );
        jPanelPagamentosLayout.setVerticalGroup(
            jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelPagamentosLayout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(jlabelemanuel1)
                .addGap(4, 4, 4)
                .addGroup(jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelPagamentosLayout.createSequentialGroup()
                        .addComponent(jButtonPagar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonConfirmar48))
                    .addGroup(jPanelPagamentosLayout.createSequentialGroup()
                        .addGroup(jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboClientes48, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonHist48))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel19)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxContracto48, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel20)
                            .addComponent(jLabelPaga))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelPagamentosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelPagamentosLayout.createSequentialGroup()
                                .addGap(11, 11, 11)
                                .addComponent(jLabelDataLimite48)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldDataLim48, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabelVP48)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldVP48, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(45, Short.MAX_VALUE))
        );

        jTabbedPane.addTab("Pagamentos", jPanelPagamentos);

        jPanel1.setBackground(resourceMap.getColor("jPanelEmpresas.background")); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jComboBox_tipoServTS.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox_tipoServTS.setName("jComboBox_tipoServTS"); // NOI18N

        jLabel_tipoServTS.setText(resourceMap.getString("jLabel_tipoServTS.text")); // NOI18N
        jLabel_tipoServTS.setName("jLabel_tipoServTS"); // NOI18N

        jButton_addTS.setIcon(resourceMap.getIcon("jButton_addTS.icon")); // NOI18N
        jButton_addTS.setText(resourceMap.getString("jButton_addTS.text")); // NOI18N
        jButton_addTS.setName("jButton_addTS"); // NOI18N
        jButton_addTS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_addTSActionPerformed(evt);
            }
        });

        jButton_alterarTS.setIcon(resourceMap.getIcon("jButton_alterarTS.icon")); // NOI18N
        jButton_alterarTS.setText(resourceMap.getString("jButton_alterarTS.text")); // NOI18N
        jButton_alterarTS.setName("jButton_alterarTS"); // NOI18N
        jButton_alterarTS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_alterarTSActionPerformed(evt);
            }
        });

        jTextField_nomeTS.setText(resourceMap.getString("jTextField_nomeTS.text")); // NOI18N
        jTextField_nomeTS.setName("jTextField_nomeTS"); // NOI18N

        jLabel_nomeTS.setText(resourceMap.getString("jLabel_nomeTS.text")); // NOI18N
        jLabel_nomeTS.setName("jLabel_nomeTS"); // NOI18N

        jButton_cancelarTS.setIcon(resourceMap.getIcon("jButton_cancelarTS.icon")); // NOI18N
        jButton_cancelarTS.setText(resourceMap.getString("jButton_cancelarTS.text")); // NOI18N
        jButton_cancelarTS.setName("jButton_cancelarTS"); // NOI18N
        jButton_cancelarTS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_cancelarTSActionPerformed(evt);
            }
        });

        jButton_guardarTS.setIcon(resourceMap.getIcon("jButton_guardarTS.icon")); // NOI18N
        jButton_guardarTS.setText(resourceMap.getString("jButton_guardarTS.text")); // NOI18N
        jButton_guardarTS.setName("jButton_guardarTS"); // NOI18N
        jButton_guardarTS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_guardarTSActionPerformed(evt);
            }
        });

        jButton_guardaAltTS.setIcon(resourceMap.getIcon("jButton_guardaAltTS.icon")); // NOI18N
        jButton_guardaAltTS.setText(resourceMap.getString("jButton_guardaAltTS.text")); // NOI18N
        jButton_guardaAltTS.setName("jButton_guardaAltTS"); // NOI18N
        jButton_guardaAltTS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_guardaAltTSActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(40, 40, 40)
                        .addComponent(jLabel_tipoServTS)
                        .addGap(18, 18, 18)
                        .addComponent(jComboBox_tipoServTS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addGap(31, 31, 31)
                                .addComponent(jButton_addTS)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButton_alterarTS))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel_nomeTS)
                                    .addComponent(jButton_cancelarTS))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField_nomeTS)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jButton_guardarTS)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jButton_guardaAltTS)))))))
                .addContainerGap(743, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox_tipoServTS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel_tipoServTS))
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_addTS)
                    .addComponent(jButton_alterarTS))
                .addGap(31, 31, 31)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField_nomeTS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel_nomeTS))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_cancelarTS, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton_guardarTS)
                    .addComponent(jButton_guardaAltTS))
                .addContainerGap(195, Short.MAX_VALUE))
        );

        jTabbedPane.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

        jPanelUtilizadores.setBackground(resourceMap.getColor("jPanelEmpresas.background")); // NOI18N
        jPanelUtilizadores.setName("jPanelUtilizadores"); // NOI18N

        jScrollPane11.setName("jScrollPane11"); // NOI18N

        jListUtil.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jListUtil.setName("jListUtil"); // NOI18N
        jListUtil.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jListUtilValueChanged(evt);
            }
        });
        jScrollPane11.setViewportView(jListUtil);

        jLabelProcUtil.setText(resourceMap.getString("jLabelProcUtil.text")); // NOI18N
        jLabelProcUtil.setName("jLabelProcUtil"); // NOI18N

        jTextFieldProcUtil.setName("jTextFieldProcUtil"); // NOI18N
        jTextFieldProcUtil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldProcUtilActionPerformed(evt);
            }
        });
        jTextFieldProcUtil.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTextFieldProcUtilFocusGained(evt);
            }
        });
        jTextFieldProcUtil.addInputMethodListener(new java.awt.event.InputMethodListener() {
            public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
                jTextFieldProcUtilInputMethodTextChanged(evt);
            }
            public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
            }
        });
        jTextFieldProcUtil.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldProcUtilKeyTyped(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextFieldProcUtilKeyReleased(evt);
            }
        });

        jLabelUser.setText(resourceMap.getString("jLabelUser.text")); // NOI18N
        jLabelUser.setName("jLabelUser"); // NOI18N

        jLabelPass.setText(resourceMap.getString("jLabelPass.text")); // NOI18N
        jLabelPass.setName("jLabelPass"); // NOI18N

        jLabelTipo.setText(resourceMap.getString("jLabelTipo.text")); // NOI18N
        jLabelTipo.setName("jLabelTipo"); // NOI18N

        jTextFieldUser.setName("jTextFieldUser"); // NOI18N

        jComboBoxTipo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Normal", "Administrador" }));
        jComboBoxTipo.setName("jComboBoxTipo"); // NOI18N

        jLabelAct.setText(resourceMap.getString("jLabelAct.text")); // NOI18N
        jLabelAct.setName("jLabelAct"); // NOI18N

        jCheckBoxAct.setName("jCheckBoxAct"); // NOI18N

        jButtonCriar.setIcon(resourceMap.getIcon("jButtonCriar.icon")); // NOI18N
        jButtonCriar.setText(resourceMap.getString("jButtonCriar.text")); // NOI18N
        jButtonCriar.setToolTipText(resourceMap.getString("jButtonCriar.toolTipText")); // NOI18N
        jButtonCriar.setName("jButtonCriar"); // NOI18N
        jButtonCriar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonCriarMouseClicked(evt);
            }
        });
        jButtonCriar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCriarActionPerformed(evt);
            }
        });

        jButtonAlt.setIcon(resourceMap.getIcon("jButtonAlt.icon")); // NOI18N
        jButtonAlt.setText(resourceMap.getString("jButtonAlt.text")); // NOI18N
        jButtonAlt.setToolTipText(resourceMap.getString("jButtonAlt.toolTipText")); // NOI18N
        jButtonAlt.setActionCommand(resourceMap.getString("jButtonAlt.actionCommand")); // NOI18N
        jButtonAlt.setName("jButtonAlt"); // NOI18N
        jButtonAlt.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonAltMouseClicked(evt);
            }
        });
        jButtonAlt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAltActionPerformed(evt);
            }
        });

        jLabelMethod.setFont(resourceMap.getFont("jLabelMethod.font")); // NOI18N
        jLabelMethod.setName("jLabelMethod"); // NOI18N

        jButtonInact.setIcon(resourceMap.getIcon("jButtonInact.icon")); // NOI18N
        jButtonInact.setText(resourceMap.getString("jButtonInact.text")); // NOI18N
        jButtonInact.setToolTipText(resourceMap.getString("jButtonInact.toolTipText")); // NOI18N
        jButtonInact.setName("jButtonInact"); // NOI18N
        jButtonInact.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonInactMouseClicked(evt);
            }
        });
        jButtonInact.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonInactActionPerformed(evt);
            }
        });

        jButtonGuardar.setIcon(resourceMap.getIcon("jButtonGuardar.icon")); // NOI18N
        jButtonGuardar.setText(resourceMap.getString("jButtonGuardar.text")); // NOI18N
        jButtonGuardar.setName("jButtonGuardar"); // NOI18N
        jButtonGuardar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonGuardarMouseClicked(evt);
            }
        });
        jButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGuardarActionPerformed(evt);
            }
        });

        Cancelar.setIcon(resourceMap.getIcon("Cancelar.icon")); // NOI18N
        Cancelar.setText(resourceMap.getString("Cancelar.text")); // NOI18N
        Cancelar.setName("Cancelar"); // NOI18N
        Cancelar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CancelarMouseClicked(evt);
            }
        });
        Cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelarActionPerformed(evt);
            }
        });

        jPasswordField1.setText(resourceMap.getString("jPasswordField1.text")); // NOI18N
        jPasswordField1.setName("jPasswordField1"); // NOI18N

        javax.swing.GroupLayout jPanelUtilizadoresLayout = new javax.swing.GroupLayout(jPanelUtilizadores);
        jPanelUtilizadores.setLayout(jPanelUtilizadoresLayout);
        jPanelUtilizadoresLayout.setHorizontalGroup(
            jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelUtilizadoresLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelProcUtil)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelUtilizadoresLayout.createSequentialGroup()
                        .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextFieldProcUtil)
                            .addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelMethod, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanelUtilizadoresLayout.createSequentialGroup()
                                .addGap(46, 46, 46)
                                .addComponent(jButtonGuardar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(Cancelar))
                            .addComponent(jLabelTipo)
                            .addComponent(jLabelAct)
                            .addGroup(jPanelUtilizadoresLayout.createSequentialGroup()
                                .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jLabelPass, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabelUser, javax.swing.GroupLayout.Alignment.LEADING))
                                .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanelUtilizadoresLayout.createSequentialGroup()
                                        .addGap(16, 16, 16)
                                        .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jComboBoxTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jCheckBoxAct)))
                                    .addGroup(jPanelUtilizadoresLayout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jPasswordField1)
                                            .addComponent(jTextFieldUser, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)))))))
                    .addGroup(jPanelUtilizadoresLayout.createSequentialGroup()
                        .addComponent(jButtonCriar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonAlt)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonInact, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(543, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanelUtilizadoresLayout.setVerticalGroup(
            jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelUtilizadoresLayout.createSequentialGroup()
                .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanelUtilizadoresLayout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jTextFieldProcUtil, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)
                            .addComponent(jLabelProcUtil)))
                    .addGroup(jPanelUtilizadoresLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabelMethod, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelUtilizadoresLayout.createSequentialGroup()
                        .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(7, 7, 7)
                        .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jButtonCriar)
                                .addComponent(jButtonAlt))
                            .addComponent(jButtonInact, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanelUtilizadoresLayout.createSequentialGroup()
                        .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelUser)
                            .addComponent(jTextFieldUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelPass)
                            .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelTipo)
                            .addComponent(jComboBoxTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelUtilizadoresLayout.createSequentialGroup()
                                .addGap(59, 59, 59)
                                .addGroup(jPanelUtilizadoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jButtonGuardar)
                                    .addComponent(Cancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(jLabelAct)
                            .addComponent(jCheckBoxAct))))
                .addContainerGap(95, Short.MAX_VALUE))
        );

        jTabbedPane.addTab(resourceMap.getString("jPanelUtilizadores.TabConstraints.tabTitle"), jPanelUtilizadores); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1114, Short.MAX_VALUE)
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 477, Short.MAX_VALUE)
                .addContainerGap())
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        jMenuItem1.setIcon(resourceMap.getIcon("jMenuItem1.icon")); // NOI18N
        jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        fileMenu.add(jMenuItem1);

        exitMenuItem.setIcon(resourceMap.getIcon("exitMenuItem.icon")); // NOI18N
        exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 1134, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 938, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void jList4ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList4ValueChanged
        if(jList4.getSelectedIndex() == -1) return;
        modelContractos = new DefaultListModel();
        //limpa as listas nao utilizadas
        jList6.setModel(new DefaultListModel());
        jTextArea_descrisaoActividadeContracto.setText(null);

        String cod = parse_cod(jList4.getSelectedValue().toString());
        Cliente cl = GCS.getClientes().get(cod);

        jTextField_nomeCliente.setText(cl.getNome());
        jTextField_BI.setText(""+cl.getNumBI());
        jTextField_NIF.setText(""+cl.getNumContribuinte());
        jTextArea_morada.setText(cl.getMorada());

        for(Contracto c : cl.getContractos().values())
            if(c.isActivo()==true)
                modelContractos.addElement(c.getCodContracto());
        jList5.setModel(modelContractos);
    }//GEN-LAST:event_jList4ValueChanged

    private void jList5ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList5ValueChanged
        if(jList5.getSelectedIndex() != -1){
            //limpa as listas nao utilizadas
            jTextArea_descrisaoActividadeContracto.setText(null);

            String cod = parse_cod(jList5.getSelectedValue().toString());
            String codCliente = parse_cod(jList4.getSelectedValue().toString());

            Contracto c = GCS.getClientes().get(codCliente).getContractos().get(cod);

            jTextField_Empresa.setText(c.getCodEmpresa()+": "+GCS.getEmpresas().get(c.getCodEmpresa()).getNome());
            jTextField_data.setText(c.getDatainicio().get(Calendar.DAY_OF_MONTH)+
                    "-"+c.getDatainicio().get(Calendar.MONTH)+
                    "-"+c.getDatainicio().get(Calendar.YEAR));
            jTextField_servico.setText(c.getCodServico()+": "+GCS.getEmpresas().get(c.getCodEmpresa()).getServicos().get(c.getCodServico()).getNome());

            DefaultListModel model_actividadesContracto = new DefaultListModel();
            for(Actividade a : c.getListaActividades().values())
                    model_actividadesContracto.addElement(a.getcodAct()+": "+a.getNome());
            jList6.setModel(model_actividadesContracto);
        }
    }//GEN-LAST:event_jList5ValueChanged

    private void jList6ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList6ValueChanged
        if(jList6.getSelectedIndex() != -1){
            //String codE = parse_cod(jTextField_Empresa.getText());
            //String codS = parse_cod(jTextField_servico.getText());

            String codCl = parse_cod(jList4.getSelectedValue().toString());
            String codC = parse_cod(jList5.getSelectedValue().toString());
            String codA = parse_cod(jList6.getSelectedValue().toString());

            //Actividade a = GCS.getEmpresas().get(codE).getServicos().get(codS).getActividades().get(codA);
            //System.out.println("***"+codA+" = "+jList6.getSelectedValue().toString());

            Actividade a = GCS.getClientes().get(codCl).getContractos().get(codC).getListaActividades().get(codA);
            if(a != null) jTextArea_descrisaoActividadeContracto.setText(a.getDesc());
            else jTextArea_descrisaoActividadeContracto.setText("NOT FOUND");
        }
    }//GEN-LAST:event_jList6ValueChanged

    private void jButton_AclienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_AclienteActionPerformed
        detalhes_tab2(true);
        botoes_tab2(false);
        detalhes_tab2_clear();
        optn = 1;
    }//GEN-LAST:event_jButton_AclienteActionPerformed

    private void jButton_cancelaAdicionarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_cancelaAdicionarClienteActionPerformed
        detalhes_tab2(false);
        botoes_tab2(true);
        detalhes_tab2_clear();
        jList5ValueChanged(null);
        jList4ValueChanged(null);
    }//GEN-LAST:event_jButton_cancelaAdicionarClienteActionPerformed

    private void jButton_confirmaAdicionarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_confirmaAdicionarClienteActionPerformed
        if(jTextField_nomeCliente.getText().equals("") ||
            jTextField_BI.getText().equals("") ||
            jTextField_NIF.getText().equals("") ||
            jTextArea_morada.getText().equals(""))
        {
            JOptionPane.showMessageDialog(null, "Preencha os campos devidamente");
            return;
        }
        int option = JOptionPane.showConfirmDialog(null, "Confirma?");
        if(option != 0) return;
        
        String cod = "";
        String nome = "";
        int BI = -1;
        int NIF = -1;
        String morada = "";
        
        nome = jTextField_nomeCliente.getText();
        BI = Integer.parseInt(jTextField_BI.getText());
        NIF = Integer.parseInt(jTextField_NIF.getText());
        morada = jTextArea_morada.getText();
        
        if(optn == 1){//criar novo
            Cliente novo = new Cliente();
            novo.setNome(nome);
            novo.setNumBI(BI);
            novo.setNumContribuinte(NIF);
            novo.setMorada(morada);
            novo.setActivo(true);

            ClientesBD cbd = new ClientesBD();
            cbd.guardaCliente(novo);

            GCS.getClientes().put(novo.getCodCliente(), novo);
            gcs.inseriHist(novo, "foi criada a sua conta de utilizador.");
        }
        if(optn == 0){//alterar
            cod = parse_cod(jList4.getSelectedValue().toString());
            Cliente alterado = new Cliente(GCS.getClientes().get(cod));
            alterado.setNome(nome);
            alterado.setNumBI(BI);
            alterado.setNumContribuinte(NIF);
            alterado.setMorada(morada);
            alterado.setActivo(true);

            ClientesBD cbd = new ClientesBD();
            cbd.updateCliente(alterado);
            GCS.getClientes().put(cod, alterado);

            gcs.inseriHist(alterado, "alterou dados da sua conta de utilizador.");
        }
        botoes_tab2(true);
        detalhes_tab2(false);
        refresh_lists();
    }//GEN-LAST:event_jButton_confirmaAdicionarClienteActionPerformed

    private void jButton_alterarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_alterarClienteActionPerformed
        if(jList4.getSelectedIndex() == -1) JOptionPane.showMessageDialog(null, "Selecione um cliente primeiro.");
        else{
            detalhes_tab2(true);
            botoes_tab2(false);
            optn =0 ;
        }
    }//GEN-LAST:event_jButton_alterarClienteActionPerformed

    private void jButton_RclienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_RclienteActionPerformed
        if(jList4.getSelectedIndex() == -1) JOptionPane.showMessageDialog(null, "Selecione um cliente primeiro.");
        else{
            if(JOptionPane.showConfirmDialog(null, "Deseja mesmo remover este cliente?") == 0){
                String cod = parse_cod(jList4.getSelectedValue().toString());
                boolean allowed = true;
                Cliente cl = new Cliente(GCS.getClientes().get(cod));

                //TODO iterator ficava melhor
                for(Contracto c : cl.getContractos().values())
                    if(c.isActivo() == true)
                        allowed = false;

                if(allowed){
                    ClientesBD cbd = new ClientesBD();
                    cl.setActivo(false);
                    cbd.updateCliente(cl);
                    GCS.getClientes().remove(cod);
                    refresh_lists();
                }else JOptionPane.showMessageDialog(null, "Cliente ainda tem contractos em vigor.");
            }
        }
    }//GEN-LAST:event_jButton_RclienteActionPerformed

    private void jButton_cancelarContractoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_cancelarContractoActionPerformed
        if(jList5.getSelectedIndex() == -1) JOptionPane.showMessageDialog(null, "Selecione um contracto primeiro.");
            else{
                if(JOptionPane.showConfirmDialog(null, "Deseja mesmo cancelar este contracto?") == 0){
                    /*String codContrato = parse_cod(jList5.getSelectedValue().toString());
                    String codCl = parse_cod(jList4.getSelectedValue().toString());
                    Contracto c = new Contracto(GCS.getClientes().get(codCl).getContractos().get(codContrato));

                    boolean allowed = true;
                    //TODO iterator ficava melhor
                    for(Prestacao p : c.getListaPrestacoes())
                        if(p.getPago() == true)
                            allowed = false;
                    if(allowed){
                        ContratoDB cdb = new ContratoDB();
                        //TODO remover contracto da base de dados
                        GCS.getClientes().get(codCl).getContractos().remove(codContrato);
                        jList4ValueChanged(null);
                    }*/
                    String codContrato = parse_cod(jList5.getSelectedValue().toString());
                    String codCl = parse_cod(jList4.getSelectedValue().toString());
                    Contracto c = new Contracto(GCS.getClientes().get(codCl).getContractos().get(codContrato));
                    
                    
                    gcs.inactivaContracto(codCl, codContrato);

                    Contabilidade cbd = new Contabilidade();
                    double valor = cbd.cancelaContr(c);
                    DecimalFormat currency = new DecimalFormat("€ #0.00");
                    JOptionPane.showMessageDialog(null, "Valor: "+currency.format(valor));
                    gcs.inseriHist(GCS.getClientes().get(codCl), "cancelou o contracto "+codContrato+".");
                    jList4ValueChanged(null);
                }
            }
    }//GEN-LAST:event_jButton_cancelarContractoActionPerformed

    private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList1ValueChanged
        if(jList1.getSelectedIndex()!=-1){
            //enable da lista dos servicos / invisible do preco
            jList2.setEnabled(true);
            precoEafinsVisible(false);
            detalhesTipoS(true);
            //limpar lista das actividades
            DefaultListModel model_vazio = new DefaultListModel();
            jList3.setModel(model_vazio);
            //inicia preenchimento
            model_servicos = new DefaultListModel();
            //parse do codigo da empresa (lista 1)
            String cod = parse_cod(jList1.getSelectedValue().toString());
            empAct = GCS.getEmpresa(cod);

            //inserir descricoes
            jLabel_nome.setText("Nome da Empresa:");
            jTextField_nome.setText(empAct.getNome());
            jTextArea_desc.setText(empAct.getDesc());
            if(empAct.getActivo()==true)
                jLabel_activo.setText("Activa: SIM");
            else
                jLabel_activo.setText("Activa: NÃO");

            //preencher lista dois com os servicos da empresa seleccionada
            for(Servico s : empAct.getServicos().values())
                model_servicos.addElement(s.getcodServ()+": "+s.getNome());
            jList2.setModel(model_servicos);

            //preencher tipos de servico
            jComboBox_tipoServ.removeAllItems();
            jComboBox_tipoServ.addItem(GCS.getTipoServico(empAct.getTipo()));

        }
}//GEN-LAST:event_jList1ValueChanged

    private void jList2ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList2ValueChanged
        if(jList2.getSelectedIndex()!=-1){
            //colocar preco invisivel e lista 3 enabled
            detalhesTipoS(false);
            jList3.setEnabled(true);
            precoEafinsVisible(false);
            //comeca o preenchimento da lista
            model_actividades = new DefaultListModel();
            //parse do codigo do servico (lista 2)
            String cod = parse_cod(jList2.getSelectedValue().toString());
            servAct = GCS.getServico(empAct.getCodEmp(),cod);

            //inserir descricoes
            jLabel_nome.setText("Nome do Serviço:");
            jTextField_nome.setText(servAct.getNome());
            jTextArea_desc.setText(servAct.getDesc());
            if(servAct.getActivo()==true)
                jLabel_activo.setText("Activo: SIM");
            else
                jLabel_activo.setText("Activo: NÃO");

            //preencher lista tres com actividades do servico seleccionado
            for(Actividade a : servAct.getActividades().values())
                model_actividades.addElement(a.getcodAct()+": "+a.getNome());
            jList3.setModel(model_actividades);
        }
}//GEN-LAST:event_jList2ValueChanged

    private void jList3ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList3ValueChanged
        if(jList3.getSelectedIndex()!=-1){
            precoEafinsVisible(true);
            detalhesTipoS(false);
            //parse do codigo da actividade (lista 3)
            String cod = parse_cod(jList3.getSelectedValue().toString());
            actAct = GCS.getActividade(empAct.getCodEmp(),servAct.getcodServ(),cod);
            Actividade a = servAct.getActividades().get(cod);

            //inserir descricoes
            jLabel_nome.setText("Nome da Actividade:");
            jTextField_nome.setText(a.getNome());
            jTextArea_desc.setText(a.getDesc());
            jTextField_preco.setText(a.getPreco()+"");
            if(a.getActivo()==true)
                jLabel_activo.setText("Activa: SIM");
            else
                jLabel_activo.setText("Activa: NÃO");
        }
}//GEN-LAST:event_jList3ValueChanged

    private void jButton_AempActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_AempActionPerformed
        //detalhes_tab1_clear();
        tipoCria=0;
        detalhesTipoS(true);
        detalhes_tabEditable(true);
        activarJLists(false);
        precoEafinsVisible(false);
        botoesGuardar(true);
        jLabel_nome.setText("Nome da Empresa:");
        jTextField_nome.setText("Insira o nome da nova empresa");
        jTextArea_desc.setText("Descrição");
        jLabel_activo.setText("Activa: SIM");
        //preencher tipos de servico
        jComboBox_tipoServ.removeAllItems();
        for(TipoServico tp : GCS.getTipoServico().values())
            jComboBox_tipoServ.addItem(tp);
}//GEN-LAST:event_jButton_AempActionPerformed

    private void jButton_AservActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_AservActionPerformed
        //detalhes_tab1_clear();
        if(jList1.getSelectedIndex()!=-1){
            tipoCria=1;
            detalhesTipoS(false);
            detalhes_tabEditable(true);
            activarJLists(false);
            precoEafinsVisible(false);
            botoesGuardar(true);
            jLabel_nome.setText("Nome do Serviço:");
            jTextField_nome.setText("Insira o nome do novo serviço");
            jTextArea_desc.setText("Descrição");
            jLabel_activo.setText("Activa: SIM");
        }else JOptionPane.showMessageDialog(null, "Por favor, seleccione a empresa à qual pertence o novo serviço.");
    }//GEN-LAST:event_jButton_AservActionPerformed

    private void jButton_InacEmpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_InacEmpActionPerformed
        if(jList1.getSelectedIndex()!=-1){
            if(gcs.empresaAssociada(empAct.getCodEmp()) == false || empAct.getActivo()==false){
                String emp = empAct.getCodEmp()+": "+empAct.getNome();
                if((JOptionPane.showConfirmDialog(null, "Deseja activar/desactivar a empresa "+emp+" ?"))==0){
                    gcs.alteraEstadoEmp(empAct.getCodEmp());
                    jList1ValueChanged(null);
                }
            }else JOptionPane.showMessageDialog(null, "Não pode desactivar empresas que estão associadas a contractos!");
        }else JOptionPane.showMessageDialog(null, "Seleccione uma empresa!");
}//GEN-LAST:event_jButton_InacEmpActionPerformed

    private void jButton_InactServActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_InactServActionPerformed
        if(jList1.getSelectedIndex()!=-1 && jList2.getSelectedIndex()!=-1){
            if(gcs.servicoAssociado(servAct.getcodServ()) == false || servAct.getActivo()==false){
                String serv =servAct.getcodServ()+": "+servAct.getNome();
                if((JOptionPane.showConfirmDialog(null, "Deseja activar/desactivar o serviço "+serv+" ?"))==0){
                    gcs.alteraEstadoServ(empAct.getCodEmp(),servAct.getcodServ());
                    jList1ValueChanged(null);
                }
            }else JOptionPane.showMessageDialog(null, "Não pode desactivar serviços que estão associados a contractos!");
        }else JOptionPane.showMessageDialog(null, "Seleccione um servico!");
}//GEN-LAST:event_jButton_InactServActionPerformed

    private void jButton_InactActActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_InactActActionPerformed
        if(jList1.getSelectedIndex()!=-1 && jList2.getSelectedIndex()!=-1 && jList3.getSelectedIndex()!=-1){
            if(gcs.actividadeAssociada(empAct.getCodEmp(),servAct.getcodServ(),actAct.getcodAct()) == false || actAct.getActivo()==false){
                String act =actAct.getcodAct()+": "+actAct.getNome();
                if((JOptionPane.showConfirmDialog(null, "Deseja activar/desactivar a actividade "+act+" ?"))==0){
                    gcs.alteraEstadoAct(empAct.getCodEmp(), servAct.getcodServ(), actAct.getcodAct());
                    jList2ValueChanged(null);
                }
            }else JOptionPane.showMessageDialog(null, "Não pode desactivar actividades que estão associadas a contractos!");
        }else JOptionPane.showMessageDialog(null, "Seleccione uma actividade!");
}//GEN-LAST:event_jButton_InactActActionPerformed

    private void jButton_AactActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_AactActionPerformed
        //detalhes_tab1_clear();
        if(jList1.getSelectedIndex()!=-1 && jList2.getSelectedIndex()!=-1){
            tipoCria=2;
            detalhesTipoS(false);
            detalhes_tabEditable(true);
            activarJLists(false);
            precoEafinsVisible(true);
            botoesGuardar(true);
            jLabel_nome.setText("Nome da Actividade:");
            jTextField_nome.setText("Insira o nome da nova actividade");
            jTextArea_desc.setText("Descrição");
            jTextField_preco.setText("");
            jLabel_activo.setText("Activa: SIM");
        }else JOptionPane.showMessageDialog(null, "Por favor, seleccione a empresa e o serviço à qual pertence a nova actividade.");
}//GEN-LAST:event_jButton_AactActionPerformed

    private void jButton_guardarESAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_guardarESAActionPerformed
        if(JOptionPane.showConfirmDialog(null, "Deseja guardar?", null, JOptionPane.YES_NO_OPTION)!=1){
        String nome="",desc="";float preco = 0;int flag=1;
        if(tipoCria == 0) {nome = "da Empresa";desc = "da Empresa";} else if(tipoCria == 1) {nome = "do Serviço";desc = "do Serviço";} else if(tipoCria == 2) {
            nome = "da Actividade";desc = "da Actividade";
            try{
                preco = Float.parseFloat(jTextField_preco.getText());
            }catch(Exception e){flag=0;JOptionPane.showMessageDialog(null, "Introduza um valor numérico válido no campo preço!");}
        }

        if(jTextField_nome.getText().length()>45){
            JOptionPane.showMessageDialog(null, "O nome "+nome+" da empresa pode conter no máximo 45 caracteres!");
        } else
            if(jTextArea_desc.getText().length()>100){
                JOptionPane.showMessageDialog(null, "A descrição "+desc+" pode conter no máximo 100 caracteres!");
            } else{if(flag==1){
                if(tipoCria==0){
                    if(jComboBox_tipoServ.getSelectedItem()!=null){
                        TipoServico tp = (TipoServico)jComboBox_tipoServ.getSelectedItem();
                        gcs.addEmpresa(jTextField_nome.getText(),jTextArea_desc.getText(),tp.getCod());
                        refresh_lists();
                        detalhes_tab1_clear();
                        detalhes_tabEditable(false);
                        jComboBox_tipoServ.setVisible(false);
                    }else JOptionPane.showMessageDialog(null, "Escolha um tipo de serviço!");
                } else if(tipoCria==1){
                    gcs.addServico(empAct.getCodEmp(),jTextField_nome.getText(),jTextArea_desc.getText());
                    //refresh_lists();
                    jList1ValueChanged(null);
                    detalhes_tab1_clear();
                    detalhes_tabEditable(false);
                } else if (tipoCria==2){

                    gcs.addActividade(empAct.getCodEmp(), servAct.getcodServ(), jTextField_nome.getText(), jTextArea_desc.getText(), preco);
                    //refresh_lists();
                    jList2ValueChanged(null);
                    detalhes_tab1_clear();
                    detalhes_tabEditable(false);
                }
                detalhesTipoS(false);
                detalhes_tabEditable(false);
                activarJLists(true);
                precoEafinsVisible(false);
                detalhes_tab1_clear();
                botoesGuardar(false);
            }
            }
        }
}//GEN-LAST:event_jButton_guardarESAActionPerformed

    private void jButton_cancelarESAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_cancelarESAActionPerformed
        activarJLists(true);
        detalhes_tab1_clear();
        detalhes_tabEditable(false);
        refresh_lists();
        botoesGuardar(false);
        botoesAlterar(false);
        detalhesTipoS(false);
}//GEN-LAST:event_jButton_cancelarESAActionPerformed

    private void jComboBox_tipoServActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox_tipoServActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jComboBox_tipoServActionPerformed

    private void jButton_alterarEmpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_alterarEmpActionPerformed
        if(jList1.getSelectedIndex()!=-1){
            tipoCria=0;
            detalhesTipoS(true);
            detalhes_tabEditable(true);
            activarJLists(false);
            precoEafinsVisible(false);
            botoesAlterar(true);
            jList1ValueChanged(null);
            //preencher tipos de servico
            jComboBox_tipoServ.removeAllItems();
            for(TipoServico tp : GCS.getTipoServico().values())
                jComboBox_tipoServ.addItem(tp);
            jComboBox_tipoServ.setSelectedItem(GCS.getTipoServico().get(empAct.getTipo()));
        }else JOptionPane.showMessageDialog(null, "Seleccione uma empresa!");
    }//GEN-LAST:event_jButton_alterarEmpActionPerformed

    private void jButton_alterarServActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_alterarServActionPerformed
        if(jList1.getSelectedIndex()!=-1 && jList2.getSelectedIndex()!=-1){
            tipoCria=1;
            detalhesTipoS(false);
            detalhes_tabEditable(true);
            activarJLists(false);
            precoEafinsVisible(false);
            botoesAlterar(true);
            jList2ValueChanged(null);
        }else JOptionPane.showMessageDialog(null, "Seleccione um serviço!");
    }//GEN-LAST:event_jButton_alterarServActionPerformed

    private void jButton_alterarActActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_alterarActActionPerformed
        if(jList1.getSelectedIndex()!=-1 && jList2.getSelectedIndex()!=-1 && jList3.getSelectedIndex()!=-1){
            tipoCria=2;
            detalhesTipoS(false);
            detalhes_tabEditable(true);
            activarJLists(false);
            precoEafinsVisible(true);
            botoesAlterar(true);
            jList3ValueChanged(null);
        }else JOptionPane.showMessageDialog(null, "Seleccione uma actividade!");
    }//GEN-LAST:event_jButton_alterarActActionPerformed

    private void jButton_guardaAltActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_guardaAltActionPerformed
        String nome="",desc="";float preco = 0;int flag=1;
        if(tipoCria == 0) {nome = "da Empresa";desc = "da Empresa";} else if(tipoCria == 1) {nome = "do Serviço";desc = "do Serviço";} else if(tipoCria == 2) {
            nome = "da Actividade";desc = "da Actividade";
            try{
                preco = Float.parseFloat(jTextField_preco.getText());
            }catch(Exception e){flag=0;JOptionPane.showMessageDialog(null, "Introduza um valor numérico válido no campo preço!");}
        }

        if(jTextField_nome.getText().length()>45){
            JOptionPane.showMessageDialog(null, "O nome "+nome+" da empresa pode conter no máximo 45 caracteres!");
        } else
            if(jTextArea_desc.getText().length()>100){
                JOptionPane.showMessageDialog(null, "A descrição "+desc+" pode conter no máximo 100 caracteres!");
            } else{if(flag==1){
                if(tipoCria==0){
                    TipoServico tp = (TipoServico)jComboBox_tipoServ.getSelectedItem();
                    gcs.updateEmpresa(empAct.getCodEmp(),jTextField_nome.getText(),jTextArea_desc.getText(),tp.getCod());
                    refresh_lists();
                    detalhes_tab1_clear();
                    detalhes_tabEditable(false);
                    detalhesTipoS(false);
                    
                } else if(tipoCria==1){
                    gcs.updateServico(empAct.getCodEmp(),servAct.getcodServ(),jTextField_nome.getText(),jTextArea_desc.getText());
                    //refresh_lists();
                    jList1ValueChanged(null);
                    detalhes_tab1_clear();
                    detalhes_tabEditable(false);
                } else if (tipoCria==2){

                    gcs.updateActividade(empAct.getCodEmp(), servAct.getcodServ(),actAct.getcodAct(), jTextField_nome.getText(), jTextArea_desc.getText(),preco);
                    //refresh_lists();
                    jList2ValueChanged(null);
                    detalhes_tab1_clear();
                    detalhes_tabEditable(false);
                }
                detalhesTipoS(false);
                detalhes_tabEditable(false);
                activarJLists(true);
                precoEafinsVisible(false);
                detalhes_tab1_clear();
                botoesAlterar(false);
            }
            }
}//GEN-LAST:event_jButton_guardaAltActionPerformed

    private void jButtonPagarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPagarActionPerformed
        Contabilidade cb = new Contabilidade();
        double res = cb.valorPagar((Contracto)jComboBoxContracto48.getSelectedItem(),GCS.getTaxalucro());
        DecimalFormat currency = new DecimalFormat("€ #0.00");
        JOptionPane.showMessageDialog(null,"Valor a pagar: "+currency.format(res),"Pagamento",JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_jButtonPagarActionPerformed

    private void jComboClientes48MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jComboClientes48MousePressed

}//GEN-LAST:event_jComboClientes48MousePressed

    private void jComboClientes48MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jComboClientes48MouseClicked

}//GEN-LAST:event_jComboClientes48MouseClicked

    private void jComboClientes48ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboClientes48ActionPerformed
        if(jComboClientes48.getSelectedItem()!=null){
            refreshContractos();
            refreshCaixas();
        }
}//GEN-LAST:event_jComboClientes48ActionPerformed

    private void jComboBoxContracto48ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxContracto48ActionPerformed
        if(jComboBoxContracto48.getSelectedItem()!=null){
            refreshPrestacoes();
            refreshCaixas();
        }
}//GEN-LAST:event_jComboBoxContracto48ActionPerformed

    private void jListPrestacoes48MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListPrestacoes48MouseClicked
        Prestacao p = (Prestacao)jListPrestacoes48.getSelectedValue();
        if(p!=null){
            if(p.getPago()){
                jLabelPaga.setText("PAGA");
                jLabelPaga.setForeground(Color.GREEN);
            }else{
                jLabelPaga.setText("NÂO PAGA");
                jLabelPaga.setForeground(Color.red);
            }
            jTextFieldDataLim48.setText(""+p.getDataLimite().get(Calendar.DAY_OF_MONTH)+"-"+p.getDataLimite().get(Calendar.MONTH)+"-"+p.getDataLimite().get(Calendar.YEAR));
            jTextFieldVP48.setText("€ "+p.getMontante());
        }
    }//GEN-LAST:event_jListPrestacoes48MouseClicked

    private void jButtonConfirmar48ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConfirmar48ActionPerformed
        Contabilidade cb = new Contabilidade();
        Cliente c = ((Cliente)jComboClientes48.getSelectedItem());
        
        if((Contracto)jComboBoxContracto48.getSelectedItem()==null)
            JOptionPane.showMessageDialog(null,"Nenhum contracto selecionado!","Erro",JOptionPane.ERROR_MESSAGE);
        else{
            if(cb.valorPagar((Contracto)jComboBoxContracto48.getSelectedItem(),2)==0.00)
                JOptionPane.showMessageDialog(null,"Nenhum pagamento em atraso.","Aviso",JOptionPane.WARNING_MESSAGE);
            else{
                Object [] opcoes = {"Confirmar","Não Confirmar"};
                int retorno = JOptionPane.showOptionDialog(null,"Confirma o pagamento do cliente "+c.getNome()+"?","Pagamento",
                        JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,opcoes,opcoes[1]);

                if(retorno==0){
                    cb.confirmarPagamento(c,(Contracto)jComboBoxContracto48.getSelectedItem());
                    JOptionPane.showMessageDialog(null,"Pagamento efectuado!","Informação",JOptionPane.INFORMATION_MESSAGE);
                    jListPrestacoes48MouseClicked(null);
                    refreshPrestacoes();
                }
                else{
                    JOptionPane.showMessageDialog(null,"Operação cancelada!","Aviso",JOptionPane.WARNING_MESSAGE);
                }
        }}
        
}//GEN-LAST:event_jButtonConfirmar48ActionPerformed

    private void jButtonHist48MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonHist48MouseClicked
        /*String hist="";
        if(jComboClientes48.getSelectedItem()!=null){
            for(Historico h : ((Cliente)jComboClientes48.getSelectedItem()).getHist())
                hist+=h.toString()+"\n";
            JOptionPane.showMessageDialog(null,hist,"Histórico de "+((Cliente)jComboClientes48.getSelectedItem()).getNome(),JOptionPane.INFORMATION_MESSAGE);
        }*/
        //frameHist f = new frameHist((Cliente)jComboClientes48.getSelectedItem());
        //f.setVisible(true);
}//GEN-LAST:event_jButtonHist48MouseClicked

    private void jListUtilValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListUtilValueChanged
        // TODO add your handling code here:
        String s = null;
        if(jListUtil.getSelectedIndex()!= -1){
            s=jListUtil.getSelectedValue().toString();
            Utilizador u = GCS.getUtilizadores().get(s);
            jTextFieldUser.setText(u.getUser());
            String pass = u.getPass();
            if(util.getTipo()==0 && !util.getUser().equals(s))
                jPasswordField1.setText(pass.replaceAll(pass, "********"));
            else
                jPasswordField1.setText(pass);
            String tipo;
            if (u.getTipo()==1)
                tipo = "Administrador";
            else
                tipo = "Normal";
            jComboBoxTipo.setSelectedItem(tipo);
            if(u.isActivo()==true)
                jCheckBoxAct.setSelected(true);
            else
                jCheckBoxAct.setSelected(false);
            if(util.getTipo()==1 || u.getUser().equals(util.getUser()))
                jButtonAlt.setEnabled(true);
            else
                jButtonAlt.setEnabled(false);
        }
}//GEN-LAST:event_jListUtilValueChanged

    private void jButtonCriarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonCriarMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonCriarMouseClicked

    private void jButtonAltMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonAltMouseClicked
        // TODO add your handling code here:
}//GEN-LAST:event_jButtonAltMouseClicked

    private void jButtonInactMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonInactMouseClicked
        // TODO add your handling code here:
}//GEN-LAST:event_jButtonInactMouseClicked

    private void jButtonGuardarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonGuardarMouseClicked
        // TODO add your handling code here:
}//GEN-LAST:event_jButtonGuardarMouseClicked

    private void CancelarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CancelarMouseClicked
        // TODO add your handling code here:
}//GEN-LAST:event_CancelarMouseClicked

    private void jButton_adicionarConctractoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_adicionarConctractoActionPerformed
        if(jList4.getSelectedIndex()!=-1){
            botoes_tab2(false);
            criaContracto c = new criaContracto(parse_cod(jList4.getSelectedValue().toString()),this);
            c.setVisible(true);
            //criaContracto.main(parse_cod(jList3.getSelectedValue().toString()));
            c.setAlwaysOnTop(true);
            //this.getApplication().hide(this);
            Component[] com = mainPanel.getComponents();
            Component[] com1 = jPanelClientes.getComponents();
            //mainPanel.a
            //mainPanel.setEnabled(false);
            for (int a = 0; a < com1.length; a++)
                com1[a].setEnabled(false);
            for (int a = 0; a < com.length; a++)
                com[a].setEnabled(false);
            jList4.setEnabled(false);
            jList5.setEnabled(false);
            jList6.setEnabled(false);
        }else JOptionPane.showMessageDialog(null, "Seleccione um cliente!");
    }//GEN-LAST:event_jButton_adicionarConctractoActionPerformed

    public void EnableTrue(){
        Component[] com = mainPanel.getComponents();
        Component[] com1 = jPanelClientes.getComponents();
        for (int a = 0; a < com1.length; a++)
            com1[a].setEnabled(true);
        for (int a = 0; a < com.length; a++)
            com[a].setEnabled(true);
        jList4.setEnabled(true);
        jList5.setEnabled(true);
        jList6.setEnabled(true);
    }
    public void EnableTrue2(){
        Component[] com = mainPanel.getComponents();
        Component[] com1 = jPanelPagamentos.getComponents();
        for (int a = 0; a < com1.length; a++)
            com1[a].setEnabled(true);
        for (int a = 0; a < com.length; a++)
            com[a].setEnabled(true);
        jListPrestacoes48.setEnabled(true);
    }



    private void jButtonCriarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCriarActionPerformed
        // TODO add your handling code here:
        jTextFieldProcUtil.setEnabled(false);
        jListUtil.setEnabled(false);
        jButtonAlt.setEnabled(false);
        jButtonCriar.setEnabled(false);
        jButtonInact.setEnabled(false);
        jButtonGuardar.setVisible(true);
        Cancelar.setVisible(true);
        jTextFieldUser.setEnabled(true);
        jPasswordField1.setEnabled(true);
        jTextFieldUser.setText("");
        jPasswordField1.setText("");
        jListUtil.clearSelection();
        jComboBoxTipo.setSelectedIndex(0);
        jCheckBoxAct.setSelected(true);
        met=0;
        jLabelMethod.setText("Criar Utilizador");
    }//GEN-LAST:event_jButtonCriarActionPerformed

    private void jButtonAltActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAltActionPerformed
        // TODO add your handling code here:
        if(jListUtil.getSelectedValue()!=null){
            jTextFieldProcUtil.setEnabled(false);
            jListUtil.setEnabled(false);
            jButtonAlt.setEnabled(false);
            jButtonCriar.setEnabled(false);
            jButtonInact.setEnabled(false);
            jButtonGuardar.setVisible(true);
            Cancelar.setVisible(true);
            jTextFieldUser.setEnabled(false);
            jPasswordField1.setEnabled(true);
            met=1;
            jLabelMethod.setText("Alterar Utilizador");
            if(util.getTipo()==1){
                jCheckBoxAct.setEnabled(true);
                jComboBoxTipo.setEnabled(true);
            }
        } else
            JOptionPane.showMessageDialog(null, "Um utilizador tem que estar seleccionado!");


        //jList1.setSelectedIndex(0);
    }//GEN-LAST:event_jButtonAltActionPerformed

    private void jButtonInactActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonInactActionPerformed
        // TODO add your handling code here:
        if(jListUtil.getSelectedValue()!=null && jCheckBoxAct.isSelected()==true){
            boolean suc;
            suc=gcs.removeUtil(jListUtil.getSelectedValue().toString());
            if(suc==true){
                JOptionPane.showMessageDialog(null, "Utilizador removido com sucesso!");
                jListUtil.clearSelection();
                model_util.removeElement(jListUtil.getSelectedValue());
                refresh();

            } else
                JOptionPane.showMessageDialog(null, "Não foi possivel remover o utilizador!");
        } else
            JOptionPane.showMessageDialog(null, "Um utilizador tem que estar seleccionado ou ja foi apagado!");
        //jList1.setSelectedIndex(0);
    }//GEN-LAST:event_jButtonInactActionPerformed

    private void jButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGuardarActionPerformed
        // TODO add your handling code here:
        boolean suc;
        int tipo;
        String s = jComboBoxTipo.getSelectedItem().toString();
        String m;
        String pass = new String(jPasswordField1.getPassword());
        if(met==0)
            m="Criado";
        else
            m="Alterado";
        if(s.equals("Normal"))
            tipo=0;
        else
            tipo=1;
        if(jTextFieldUser.getText().equals("") && pass.equals(""))
            JOptionPane.showMessageDialog(null, "Existem campos vazios!");
        else{
            if(m.equals("Criado"))
                suc = gcs.criaUtil(jTextFieldUser.getText(),pass,tipo,jCheckBoxAct.isSelected());
            else
                suc = gcs.altUtil(jTextFieldUser.getText(), pass, tipo, jCheckBoxAct.isSelected());
            if (suc==true){
                if(m.equals("Criado")) model_util.addElement(jTextFieldUser.getText());
                JOptionPane.showMessageDialog(null, "Utilizador "+m+" com sucesso!");
                refresh();
                opbutton();
            } else
                JOptionPane.showMessageDialog(null, "Utilizador "+m+" com insucesso");
        }
    }//GEN-LAST:event_jButtonGuardarActionPerformed

    private void CancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelarActionPerformed
        // TODO add your handling code here:
        opbutton();
    }//GEN-LAST:event_CancelarActionPerformed

    private void jTabbedPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPaneStateChanged
        if(jTabbedPane.getSelectedComponent().getName().equals("jPanelUtilizadores")){
            refresh();
            jTextFieldUser.setEnabled(false);
            jPasswordField1.setEnabled(false);
            util = GCS.getUtilizadorLoggado();
            jCheckBoxAct.setEnabled(false);
            jComboBoxTipo.setEnabled(false);
            jButtonGuardar.setVisible(false);
            Cancelar.setVisible(false);
            if(util.getTipo()==0){
                jButtonCriar.setVisible(false);
                jButtonAlt.setEnabled(false);
                jButtonInact.setVisible(false);
            }
        }else if(jTabbedPane.getSelectedComponent().getName().equals("jPanel1")){
                detalhesTipoServAltera(false);
                detalhesTipoServCria(false);
                jComboBox_tipoServTS.removeAllItems();
                for(TipoServico ts : GCS.getTipoServico().values())
                    jComboBox_tipoServTS.addItem(ts);
            }else if(jTabbedPane.getSelectedComponent().getName().equals("jPanelEmpresas")){
                    detalhes_tabEditable(false);
                    detalhes_tab1_clear();
                    precoEafinsVisible(false);
                    jComboBox_tipoServ.setVisible(false);
                    jButton_guardaAlt.setVisible(false);
                    jButton_cancelarESA.setVisible(false);
                    jButton_guardarESA.setVisible(false);
                    jButton_guardaAlt.setEnabled(false);
                    jButton_cancelarESA.setEnabled(false);
                    jButton_guardarESA.setEnabled(false);
                    model_empresas = new DefaultListModel();
                    for(Empresa e : GCS.getEmpresas().values())
                        model_empresas.addElement(e.getCodEmp()+": "+e.getNome());
                    jList1.setModel(model_empresas);
            }else if (jTabbedPane.getSelectedComponent().getName().equals("jPanelClientes")){
                refresh_lists();
                detalhes_tab2_clear();
            }else if(jTabbedPane.getSelectedComponent().getName().equals("jPanelPagamentos")){
                DefaultListModel d = new DefaultListModel();
                jListPrestacoes48.setModel(d);
                refreshPagamentos();
            }
    }//GEN-LAST:event_jTabbedPaneStateChanged

    private void jButton_addTSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_addTSActionPerformed
        detalhesTipoServCria(true);
        detalhesTipoServBase(false);
        jTextField_nomeTS.setText("");
    }//GEN-LAST:event_jButton_addTSActionPerformed

    private void jButton_cancelarTSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_cancelarTSActionPerformed
        detalhesTipoServAltera(false);
        detalhesTipoServCria(false);
        detalhesTipoServBase(true);
    }//GEN-LAST:event_jButton_cancelarTSActionPerformed

    private void jButton_alterarTSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_alterarTSActionPerformed
        if(jComboBox_tipoServTS.getSelectedItem()!=null){
            detalhesTipoServAltera(true);
            detalhesTipoServBase(false);
            jTextField_nomeTS.setText(((TipoServico)jComboBox_tipoServTS.getSelectedItem()).getTipo());
        }else JOptionPane.showMessageDialog(null, "Escolha um tipo de serviço!");
    }//GEN-LAST:event_jButton_alterarTSActionPerformed

    private void jButton_guardarTSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_guardarTSActionPerformed
        if(JOptionPane.showConfirmDialog(null, "Guardar novo tipo de serviço?","Confirmação",JOptionPane.YES_NO_OPTION)!=1){
            gcs.guardaTipoServ(jTextField_nomeTS.getText());
            detalhesTipoServCria(false);
            detalhesTipoServBase(true);
            jTabbedPaneStateChanged(null);
        }
    }//GEN-LAST:event_jButton_guardarTSActionPerformed

    private void jButton_guardaAltTSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_guardaAltTSActionPerformed
        if(JOptionPane.showConfirmDialog(null, "Guardar alterações?","Confirmação",JOptionPane.YES_NO_OPTION)!=1){
            TipoServico ts = (TipoServico)jComboBox_tipoServTS.getSelectedItem();
            gcs.updateTipoServ(ts.getCod(), jTextField_nomeTS.getText());
            detalhesTipoServAltera(false);
            detalhesTipoServBase(true);
            jTabbedPaneStateChanged(null);
        }
    }//GEN-LAST:event_jButton_guardaAltTSActionPerformed

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        GCSApp.getApplication().hide(this);
        Autenticacao a = new Autenticacao();
        a.setVisible(true);
        
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jButtonHist48ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonHist48ActionPerformed
        /*// TODO add your handling code here:
        frameHist f = new frameHist((Cliente)jComboClientes48.getSelectedItem());
        f.setVisible(true);
        f.setAlwaysOnTop(true);
        //this.getApplication().hide(this);
        Component[] com = mainPanel.getComponents();
        Component[] com1 = jPanelPagamentos.getComponents();
        //mainPanel.a
        //mainPanel.setEnabled(false);
        for (int a = 0; a < com1.length; a++)
            com1[a].setEnabled(false);
        for (int a = 0; a < com.length; a++)
            com[a].setEnabled(false);*/

        //this.getApplication().hide(this);
        Component[] com = mainPanel.getComponents();
        Component[] com1 = jPanelPagamentos.getComponents();
        //mainPanel.a
        //mainPanel.setEnabled(false);
        for (int a = 0; a < com1.length; a++)
            com1[a].setEnabled(false);
        for (int a = 0; a < com.length; a++)
            com[a].setEnabled(false);

        detalhes_hist(false);
        frameHist f = new frameHist((Cliente)jComboClientes48.getSelectedItem(),com,com1,this);
        f.setVisible(true);
        f.setAlwaysOnTop(true);
    }//GEN-LAST:event_jButtonHist48ActionPerformed

    private void jButton_adicionarActividadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_adicionarActividadeActionPerformed
        // TODO add your handling code here:
        if(jList5.getSelectedValue()!=null && jList4.getSelectedValue()!=null){
            String cod = parse_cod(jList5.getSelectedValue().toString());
            String codCliente = parse_cod(jList4.getSelectedValue().toString());
            Contracto c = GCS.getClientes().get(codCliente).getContractos().get(cod);
            AddAct_Contr ac = new AddAct_Contr(c, this,1);
            ac.setVisible(true);
            ac.setAlwaysOnTop(true);
            //this.getApplication().hide(this);
            Component[] com = mainPanel.getComponents();
            Component[] com1 = jPanelClientes.getComponents();
            //mainPanel.a
            //mainPanel.setEnabled(false);
            for (int a = 0; a < com1.length; a++)
                com1[a].setEnabled(false);
            for (int a = 0; a < com.length; a++)
                com[a].setEnabled(false);
            
        }
    }//GEN-LAST:event_jButton_adicionarActividadeActionPerformed

    private void jButton_historicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_historicoActionPerformed
        /*if(jList4.getSelectedValue()!=null){
            String cod = parse_cod(jList4.getSelectedValue().toString());
            frameHist f = new frameHist(GCS.getClientes().get(cod));
            f.setVisible(true);
            f.setAlwaysOnTop(true);
            //this.getApplication().hide(this);
            Component[] com = mainPanel.getComponents();
            Component[] com1 = jPanelClientes.getComponents();
            //mainPanel.a
            //mainPanel.setEnabled(false);
            for (int a = 0; a < com1.length; a++)
                com1[a].setEnabled(false);
            for (int a = 0; a < com.length; a++)
                com[a].setEnabled(false);
            jList4.setEnabled(false);
            jList5.setEnabled(false);
            jList6.setEnabled(false);
        }else JOptionPane.showMessageDialog(null, "Seleccione um cliente.");*/
        if(jList4.getSelectedValue()!=null){
            String cod = parse_cod(jList4.getSelectedValue().toString());

            //this.getApplication().hide(this);
            Component[] com = mainPanel.getComponents();
            Component[] com1 = jPanelClientes.getComponents();
            //mainPanel.a
            //mainPanel.setEnabled(false);
            for (int a = 0; a < com1.length; a++)
                com1[a].setEnabled(false);
            for (int a = 0; a < com.length; a++)
                com[a].setEnabled(false);
            detalhes_hist(false);

            frameHist f = new frameHist(GCS.getClientes().get(cod),com,com1,this);
            f.setVisible(true);
            f.setAlwaysOnTop(true);

        }else JOptionPane.showMessageDialog(null, "Seleccione um cliente.");
    }//GEN-LAST:event_jButton_historicoActionPerformed

    private void jTextField4FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField4FocusGained
        jTextField4.selectAll();
    }//GEN-LAST:event_jTextField4FocusGained

    private void jTextField4KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField4KeyReleased
        DefaultListModel model =new DefaultListModel();
        String s = jTextField4.getText();
        jList4.clearSelection();
        for(int i=0;i<modelClientes.getSize();i++){
            //System.out.println(modelClientes.get(i).toString().indexOf(s));
            if(modelClientes.get(i).toString().matches("(?i).*"+s+".*")==true){
                    model.addElement(modelClientes.get(i));

            }
        }
        jList4.setModel(model);
    }//GEN-LAST:event_jTextField4KeyReleased

    private void jTextField5FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField5FocusGained
        jTextField5.selectAll();
    }//GEN-LAST:event_jTextField5FocusGained

    private void jTextField1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField1FocusGained
        jTextField1.selectAll();
    }//GEN-LAST:event_jTextField1FocusGained

    private void jTextField2FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField2FocusGained
        jTextField2.selectAll();
    }//GEN-LAST:event_jTextField2FocusGained

    private void jTextField3FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField3FocusGained
        jTextField3.selectAll();
    }//GEN-LAST:event_jTextField3FocusGained

    private void jTextFieldProcUtilFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldProcUtilFocusGained
        jTextFieldProcUtil.selectAll();
    }//GEN-LAST:event_jTextFieldProcUtilFocusGained

    private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyReleased
        DefaultListModel new_model = new DefaultListModel();
        String s = jTextField1.getText();
        jList1.clearSelection();
        for(int i=0;i<model_empresas.getSize();i++){
            //System.out.println(model_empresas.get(i).toString().indexOf(s));
            if(model_empresas.get(i).toString().matches("(?i).*"+s+".*")==true){
                    new_model.addElement(model_empresas.get(i));
            }
        }
        jList1.setModel(new_model);
    }//GEN-LAST:event_jTextField1KeyReleased

    private void jTextField2KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField2KeyReleased
        DefaultListModel new_model = new DefaultListModel();
        String s = jTextField2.getText();
        jList2.clearSelection();
        for(int i=0;i<model_servicos.getSize();i++){
            //System.out.println(model_empresas.get(i).toString().indexOf(s));
            if(model_servicos.get(i).toString().matches("(?i).*"+s+".*")==true){
                    new_model.addElement(model_servicos.get(i));
            }
        }
        jList2.setModel(new_model);

    }//GEN-LAST:event_jTextField2KeyReleased

    private void jTextField3KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField3KeyReleased
        DefaultListModel new_model = new DefaultListModel();
        String s = jTextField3.getText();
        jList3.clearSelection();
        for(int i=0;i<model_actividades.getSize();i++){
            if(model_actividades.get(i).toString().matches("(?i).*"+s+".*")==true){
                    new_model.addElement(model_actividades.get(i));
            }
        }
        jList3.setModel(new_model);
    }//GEN-LAST:event_jTextField3KeyReleased

    private void jTextField5KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField5KeyReleased
        DefaultListModel model =new DefaultListModel();
        String s = jTextField5.getText();
        jList5.clearSelection();
        for(int i=0;i<modelContractos.getSize();i++){
            //System.out.println(modelContractos.get(i).toString().indexOf(s));
            if(modelContractos.get(i).toString().matches("(?i).*"+s+".*")==true){
                    model.addElement(modelContractos.get(i));

            }
        }
        jList5.setModel(model);
    }//GEN-LAST:event_jTextField5KeyReleased

    private void jTextFieldProcUtilKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldProcUtilKeyReleased
        DefaultListModel model_util1 = new DefaultListModel();
        String s = jTextFieldProcUtil.getText();
        jListUtil.clearSelection();
        for(int i=0;i<model_util.getSize();i++){
            //System.out.println(model_util.get(i).toString().indexOf(s));
            if(model_util.get(i).toString().matches("(?i).*"+s+".*")==true){
                    model_util1.addElement(model_util.get(i));

            }
        }
        jListUtil.setModel(model_util1);
    }//GEN-LAST:event_jTextFieldProcUtilKeyReleased

    private void jTextFieldProcUtilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldProcUtilActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldProcUtilActionPerformed

    private void jTextFieldProcUtilInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_jTextFieldProcUtilInputMethodTextChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldProcUtilInputMethodTextChanged

    private void jTextFieldProcUtilKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldProcUtilKeyTyped
        // TODO add your handling code here:
        
    }//GEN-LAST:event_jTextFieldProcUtilKeyTyped

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Cancelar;
    private javax.swing.JButton jButtonAlt;
    private javax.swing.JButton jButtonConfirmar48;
    private javax.swing.JButton jButtonCriar;
    private javax.swing.JButton jButtonGuardar;
    private javax.swing.JButton jButtonHist48;
    private javax.swing.JButton jButtonInact;
    private javax.swing.JButton jButtonPagar;
    private javax.swing.JButton jButton_Aact;
    private javax.swing.JButton jButton_Acliente;
    private javax.swing.JButton jButton_Aemp;
    private javax.swing.JButton jButton_Aserv;
    private javax.swing.JButton jButton_InacEmp;
    private javax.swing.JButton jButton_InactAct;
    private javax.swing.JButton jButton_InactServ;
    private javax.swing.JButton jButton_Rcliente;
    private javax.swing.JButton jButton_addTS;
    private javax.swing.JButton jButton_adicionarActividade;
    private javax.swing.JButton jButton_adicionarConctracto;
    private javax.swing.JButton jButton_alterarAct;
    private javax.swing.JButton jButton_alterarCliente;
    private javax.swing.JButton jButton_alterarEmp;
    private javax.swing.JButton jButton_alterarServ;
    private javax.swing.JButton jButton_alterarTS;
    private javax.swing.JButton jButton_cancelaAdicionarCliente;
    private javax.swing.JButton jButton_cancelarContracto;
    private javax.swing.JButton jButton_cancelarESA;
    private javax.swing.JButton jButton_cancelarTS;
    private javax.swing.JButton jButton_confirmaAdicionarCliente;
    private javax.swing.JButton jButton_guardaAlt;
    private javax.swing.JButton jButton_guardaAltTS;
    private javax.swing.JButton jButton_guardarESA;
    private javax.swing.JButton jButton_guardarTS;
    private javax.swing.JButton jButton_historico;
    private javax.swing.JCheckBox jCheckBoxAct;
    private javax.swing.JComboBox jComboBoxContracto48;
    private javax.swing.JComboBox jComboBoxTipo;
    private javax.swing.JComboBox jComboBox_tipoServ;
    private javax.swing.JComboBox jComboBox_tipoServTS;
    private javax.swing.JComboBox jComboClientes48;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelAct;
    private javax.swing.JLabel jLabelDataLimite48;
    private javax.swing.JLabel jLabelMethod;
    private javax.swing.JLabel jLabelPaga;
    private javax.swing.JLabel jLabelPass;
    private javax.swing.JLabel jLabelProcUtil;
    private javax.swing.JLabel jLabelTipo;
    private javax.swing.JLabel jLabelUser;
    private javax.swing.JLabel jLabelVP48;
    private javax.swing.JLabel jLabel_activo;
    private javax.swing.JLabel jLabel_desc;
    private javax.swing.JLabel jLabel_euros;
    private javax.swing.JLabel jLabel_nome;
    private javax.swing.JLabel jLabel_nomeTS;
    private javax.swing.JLabel jLabel_preco;
    private javax.swing.JLabel jLabel_tipoS;
    private javax.swing.JLabel jLabel_tipoServTS;
    private javax.swing.JList jList1;
    private javax.swing.JList jList2;
    private javax.swing.JList jList3;
    private javax.swing.JList jList4;
    private javax.swing.JList jList5;
    private javax.swing.JList jList6;
    private javax.swing.JList jListPrestacoes48;
    private javax.swing.JList jListUtil;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanelClientes;
    private javax.swing.JPanel jPanelEmpresas;
    private javax.swing.JPanel jPanelPagamentos;
    private javax.swing.JPanel jPanelUtilizadores;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JTabbedPane jTabbedPane;
    private javax.swing.JTextArea jTextArea_desc;
    private javax.swing.JTextArea jTextArea_descrisaoActividadeContracto;
    private javax.swing.JTextArea jTextArea_morada;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextFieldDataLim48;
    private javax.swing.JTextField jTextFieldProcUtil;
    private javax.swing.JTextField jTextFieldUser;
    private javax.swing.JTextField jTextFieldVP48;
    private javax.swing.JTextField jTextField_BI;
    private javax.swing.JTextField jTextField_Empresa;
    private javax.swing.JTextField jTextField_NIF;
    private javax.swing.JTextField jTextField_data;
    private javax.swing.JTextField jTextField_nome;
    private javax.swing.JTextField jTextField_nomeCliente;
    private javax.swing.JTextField jTextField_nomeTS;
    private javax.swing.JTextField jTextField_preco;
    private javax.swing.JTextField jTextField_servico;
    private javax.swing.JLabel jlabelemanuel1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;

    private void refresh_lists() {
        modelClientes = new DefaultListModel();
        for(Cliente c : GCS.getClientes().values())
            if(c.isActivo())
                modelClientes.addElement(c.getCodCliente()+": " + c.getNome());
        
        jList2.setModel(new DefaultListModel());
        jList3.setModel(new DefaultListModel());
        jList4.setModel(modelClientes);
        jList5.setModel(new DefaultListModel());
        jList6.setModel(new DefaultListModel());
    }
    private void activarJLists(boolean b){
        jList1.setEnabled(b);
        jList2.setEnabled(b);
        jList3.setEnabled(b);
    }
    private String parse_cod(String cod){
        String clean = "";
        String[] strs;
        strs = cod.split(":");
        clean = strs[0];
        return clean;
    }
    private void precoEafinsVisible(boolean b){
        jTextField_preco.setVisible(b);
        jLabel_preco.setVisible(b);
    }
    private void botoesAlterar(boolean b){
        jButton_cancelarESA.setVisible(b);
        jButton_guardaAlt.setVisible(b);
        jButton_cancelarESA.setEnabled(b);
        jButton_guardaAlt.setEnabled(b);
    }
    private void botoesGuardar(boolean b){
        jButton_cancelarESA.setVisible(b);
        jButton_guardarESA.setVisible(b);
        jButton_cancelarESA.setEnabled(b);
        jButton_guardarESA.setEnabled(b);
    }
    private void detalhesTipoS(boolean b){
        jComboBox_tipoServ.setVisible(b);
        jComboBox_tipoServ.setEnabled(b);
        jLabel_tipoS.setVisible(b);
        jLabel_tipoS.setEnabled(b);
    }

    private void refreshPagamentos(){
        jComboClientes48.removeAllItems();
        for(Cliente c : GCS.getClientes().values()){
            if(c.isActivo() && c.getContractos().size()>0)
                jComboClientes48.addItem(c);
        }
    }

    private void refreshContractos(){
        jComboBoxContracto48.removeAllItems();
        for(Contracto c : ((Cliente) jComboClientes48.getSelectedItem()).getContractos().values())
            if(c.isActivo())
                jComboBoxContracto48.addItem(c);
    }

    private void refreshPrestacoes(){
        jListPrestacoes48.setModel(new DefaultListModel());
        DefaultListModel novo = new DefaultListModel();
        for(Prestacao p : ((Contracto)jComboBoxContracto48.getSelectedItem()).getListaPrestacoes())
            novo.addElement(p);
        jListPrestacoes48.setModel(novo);
    }

    private void refreshCaixas(){
        jLabelPaga.setText("");
        jTextFieldDataLim48.setText("");
        jTextFieldVP48.setText("");
    }
    private void detalhesTipoServCria(boolean b){
        jLabel_nomeTS.setVisible(b);
        jTextField_nomeTS.setVisible(b);
        jButton_cancelarTS.setVisible(b);
        jButton_guardarTS.setVisible(b);
        jButton_cancelarTS.setEnabled(b);
        jButton_guardarTS.setEnabled(b);
    }
    private void detalhesTipoServAltera(boolean b){
        jLabel_nomeTS.setVisible(b);
        jTextField_nomeTS.setVisible(b);
        jButton_cancelarTS.setVisible(b);
        jButton_cancelarTS.setEnabled(b);
        jButton_guardaAltTS.setVisible(b);
        jButton_guardaAltTS.setEnabled(b);
    }
    public void detalhesTipoServBase(boolean b){
        jComboBox_tipoServTS.setEnabled(b);
        jButton_alterarTS.setEnabled(b);
        jButton_addTS.setEnabled(b);
    }
    public void actualizaConts(){jList4ValueChanged(null);}

    public void detalhes_hist(boolean b){
        jList4.setEnabled(b);
        jList5.setEnabled(b);
        jList6.setEnabled(b);
        jListPrestacoes48.setEnabled(b);
    }
}
